aLec15b_FSM_C - Introduction to Embedded Microcomputer...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/28/2011 for the course EE 16345 taught by Professor Yerraballi during the Spring '11 term at University of Texas at Austin.

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 Right Arrow Icon
Ask a homework question - tutors are online