Lec 7 Notes
Lec 7 Notes
Lec 7 Notes
Recap
Data structures: Arrays, strings
Indexed addressing, i=index, buf is base address
Size Assembly C
Byte buf+i buf[i]
Halfword buf +2*i buf[i]
Word buf +4*i buf[i]
Size_N buf +N*i buf[i]
Outline
1. PLL
2. struct to make data structures
3. Finite State Machine
4. Introduction to interrupts
Crystal
What: silicone lattice that resonates at selected frequency, 16.000 MHz
Why: time accuracy ±50ppm
How: soldered onto LaunchPad
PLL
What: analog circuit: input clock to output clock (faster or slower)
Why: software speed versus system power tradeoff
How: call PLL_Init
struct
list of things of different types
struct State{
uint32_t out; // 2-bit output
uint32_t delay; // time to delay in 1ms
uint32_t next[4]; // Next if 2-bit input is 0-3
};
typedef const struct State State_t;
State_t thing;
SysTick_Wait10ms(thing.Time);
State_t bunch[10];
SysTick_Wait10ms(bunch[n].Time);
State_t *pt;
pt = bunch; // pt = &bunch[0];
SysTick_Wait10ms(pt->Time);
Lecture 7
Software abstraction
What is abstraction?
Define a problem with a minimal set of basic, abstract principles / concepts
Separation of what it does (policy) from how it works (mechanisms)
Straightforward, mechanical path to implementation
Moore FSM
output value depends only on the current state,
inputs affect the state transitions
significance is being in a state
Input: when to change state
Output: definition of being in that state
Hardware
Draw state transition table (STT), Draw state transition graph (STG), show C code for machine
State \ Input 00(lost) 01(left) 10 (right) 11 (on line)
struct State {
Lecture 7
#define Nice 0
#define OffL 1
#define OffR 2
State_t fsm[3]={
{0x03, 50, { OffR, OffL, OffR, Nice }}, // Nice
{0x02, 50, { OffL, OffL, Nice, Nice }}, // OffL
{0x01, 50, { OffR, Nice, OffR, Nice }} // OffR
};
void main(void) {
uint32 CS; // index of current state
uint32_t Input;
uint32_t Input;
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: