{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

aLec15b_FSM_C

# aLec15b_FSM_C - Introduction to Embedded Microcomputer...

This preview shows pages 1–2. Sign up to view the full content.

Introduction to Embedded Microcomputer Systems Lecture 15.1 Jonathan W. Valvano Recap Finite State Machines Being in a state has meaning Moore: the output is related to being in a state Mealy: the output is required to change state Arrows are state transitions: pointers 1-1 mapping from state graph to data structure Overview Finite State Machines (Section 8.7) State graph to C Pointer is an address Figure 6.1. Pointers are addresses pointing to objects. The objects may be data, functions, or other pointers. We have used arrays in Lab 4 We have used the stack for subroutine calls Lab 5 will create a graph in assembly This lecture will implement the FSM in C Arrays in C: Put in RAM if you want to change values unsigned short Buffer[8]; Arrays in C: Put in ROM if values are fixed const char Data[4]= {0x05,0x06,0x0A,0x09}; Arrays Length Precision Signed/unsigned RAM or ROM Access arrays by index unsigned char Index; void Stepper_Init(void){ DDRT |= 0x0F; // PT3-0 are outputs PTT = 0x09; // first data Index = 0; // first index } void Stepper_CW(void){ PTT = Data[Index]; // rotate 15deg Index = 0x03&(Index+1); // next index } Access arrays by pointer unsigned char *Pt; void Stepper_Init(void){ DDRT |= 0x0F; // PT3-0 are outputs PTT = 0x09; // first data Pt = Data; // pointer to first } void Stepper_CW(void){ PTT = *Pt; // rotate 15deg if(Pt == &Data[3]){ Pt = Data; // pointer to first

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

aLec15b_FSM_C - Introduction to Embedded Microcomputer...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online