EE 319K Introduction to Embedded Systems

Slides:



Advertisements
Similar presentations
11-1 Bard, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 11: Data Acquisition, Numerical Fixed-Point Calculations, Lab.
Advertisements

13-1 Bard, Gerstlauer, Valvano, Erez, Telang, Yerraballi EE 319K Introduction to Embedded Systems Lecture 13: 2-D Arrays, Bitmaps, Sprites, Structs, Lab.
EE 319K Introduction to Embedded Systems
Chapter #10: Finite State Machine Implementation
4-1 EE 319K Introduction to Embedded Systems Lecture 4: Arithmetic overflow, Branches, Control Structures, Abstraction & Refinement Bard, Erez, Gerstlauer,
1-1 Bard, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Microcontrollers Lecture 1: Introduction, Embedded Systems, Product Life-Cycle, ARM Programming.
4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
8051 Core Specification.
10-1 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 10: Sampling, Analog-to-Digital.
ECE 331 – Digital System Design
Modern VLSI Design 2e: Chapter 5 Copyright  1998 Prentice Hall PTR Topics n Sequential machine implementation: –clocking. n Sequential machine design.
ECE C03 Lecture 101 Lecture 10 Finite State Machine Design Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Contemporary Logic Design Finite State Machine Design © R.H. Katz Transparency No Chapter #8: Finite State Machine Design 8.5 Finite State Machine.
1 Lecture 14: FSM and Basic CPU Design Today’s topics:  Finite state machines  Single-cycle CPU Reminder: midterm on Tue 10/24  will cover Chapters.
11-1 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 11: Data Acquisition, Numerical.
7-1 EE 319K Introduction to Embedded Systems Lecture 7: Phase-locked-loop, Data structures, Finite state machines, Interrupts Bard, Gerstlauer, Valvano,
ECE 331 – Digital Systems Design Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #19)
6-1 EE 319K Introduction to Embedded Systems Lecture 6: SysTick Timer, Exam 1 Review Bard, Erez, Gerstlauer, Valvano, Yerraballi, Telang, Janapa Reddi,
11/10/ :53:59 AMweek12-3.ppt1 Intelligent Traffic Controller We want to use a finite state machine to control the traffic lights at an intersection.
1 COMP541 State Machines Montek Singh Feb 8, 2012.
PIT: Programmable Interval Timer
EE434 ASIC & Digital Systems
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
Computer Organization & Programming Chapter 5 Synchronous Components.
EE 319K Introduction to Microcontrollers
Ch. 6 Pointers and Data Structures From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12.
Modern VLSI Design 4e: Chapter 5 Copyright  2008 Wayne Wolf Topics n Sequential machine implementation: –clocking. n Sequential machine design.
Light Sensors ECE 4437 Dr. J. Glover Team 9: Jitin George Zachary Freeman.
Digital System Design using VHDL
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
EE 319K Introduction to Embedded Systems
1 COMP541 Finite State Machines - 1 Montek Singh Sep 22, 2014.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Embedded Systems Lecture 4 January 20, 2016.
Finite State Machine. Clock Clock cycle Sequential circuit Digital logic systems can be classified as combinational or sequential. – Combinational circuits.
Interrupt, again! Lin Zhong ELEC424, Fall 2010.
Common Elements in Sequential Design. Lecture 3 topics  Registers and Register Transfer  Shift Registers  Counters Basic Counter Partial sequence counters.
1 COMP541 Sequential Logic – 2: Finite State Machines Montek Singh Feb 29, 2016.
George Mason University Finite State Machines Refresher ECE 545 Lecture 11.
1 The LPC1768 Architecture (with focus on Cortex-M3)
Controller Implementation
Finite State Machines Mealy machine inputs Outputs next state function
Sequential Networks and Finite State Machines
Lecture 4. Sequential Logic #2
Microcontrollers & GPIO
EE 319K Introduction to Embedded Systems
UNIT – I Linked Lists.
COMP541 Sequential Logic – 2: Finite State Machines
ECEN 248 Lab 9: Design of a Traffic Light Controller
Programmable Interval Timer
Refer to Chapter 3 in the reference book
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Sequential Networks and Finite State Machines
CSCI1600: Embedded and Real Time Software
Lecture 13: Sequential Circuits, FSM
AT91 Memory Interface This training module describes the External Bus Interface (EBI), which generatesthe signals that control the access to the external.
CSE 140L Discussion Finite State Machines.
Lecture 13: Sequential Circuits, FSM
CSE 370 – Winter Sequential Logic-2 - 1
CSE 370 – Winter Sequential Logic-2 - 1
Basics of Embedded Systems IAX0230 Embedded Software Programming
Basics of Embedded Systems IAX0230 Time Interfacing
Lecture 14: State Tables, Diagrams, Latches, and Flip Flop
CSCI1600: Embedded and Real Time Software
Finite State Machine Continued
Lecture 4: Finite State Machines
Presentation transcript:

EE 319K Introduction to Embedded Systems Lecture 4: Data structures, Finite state machines

Agenda Outline More on SysTick Timer Bit Specific Addressing Data structures Finite State Machines, Indexed Implementation. Interrupts

SysTick Timer in C #define NVIC_ST_CTRL_R(*((volatile uint32_t *)0xE000E010)) #define NVIC_ST_RELOAD_R(*((volatile uint32_t *)0xE000E014)) #define NVIC_ST_CURRENT_R(*((volatile uint32_t *)0xE000E018)) void SysTick_Init(void){ NVIC_ST_CTRL_R = 0; // 1) disable SysTick during setup NVIC_ST_RELOAD_R = 0x00FFFFFF; // 2) maximum reload value NVIC_ST_CURRENT_R = 0; // 3) any write to CURRENT clears it NVIC_ST_CTRL_R = 0x00000005; // 4) enable SysTick with core clock } // The delay parameter is in units of the 80 MHz core clock(12.5 ns) void SysTick_Wait(uint32_t delay){ NVIC_ST_RELOAD_R = delay-1; // number of counts NVIC_ST_CURRENT_R = 0; // any value written to CURRENT clears while((NVIC_ST_CTRL_R&0x00010000)==0){ // wait for flag // Call this routine to wait for delay*10ms void SysTick_Wait10ms(uint32_t delay){ unsigned long i; for(i=0; i<delay; i++){ SysTick_Wait(800000); // wait 10ms Bard, Gerstlauer, Valvano, Yerraballi

I/O Port Bit-Specific I/O Port bit-specific addressing is used to access port data register Define address offset as 4*2b, where b is the selected bit position 256 possible bit combinations (0-8) Add offsets for each bit selected to base address for the port Example: PF4 and PF0 Port F = 0x4005.D000 0x4005.D000+0x0004+0x0040 = 0x4005.D044 Provides friendly and atomic access to port pins

Recap: Array access Calculate address from Base and index Byte Base+index Halfword Base+2*index Word Base+4*index Size_N Base+N*index Access sequentially using pointers Byte pt = pt+1 Halfword pt = pt+2 Word pt = pt+4 Size_N pt = pt+N

Abstraction Software abstraction Three advantages of abstraction are Define a problem with a minimal set of basic, abstract principles / concepts Separation of concerns via interface/policy mechanisms Straightforward, mechanical path to implementation Three advantages of abstraction are it can be faster to develop it is easier to debug (prove correct) and it is easier to change

Finite State Machine (FSM) Finite State Machines (FSMs) Set of inputs, outputs, states and transitions State graph defines input/output relationship What is a state? Description of current conditions What is a state graph? Graphical interconnection between states What is a controller? Software that inputs, outputs, changes state Accesses the state graph

Finite State Machine (FSM) What is a finite state machine? Inputs (sensors) Outputs (actuators) States State Transition Graph Output Determination

Finite State Machine (FSM) 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

Finite State Machine (FSM) Moore FSM Execution Sequence Perform output corresponding to the current state Wait a prescribed amount of time (optional) Read inputs Change state, which depends on the input and the current state Go back to 1. and repeat

Finite State Machine (FSM) Mealy FSM output value depends on input and current state inputs affect the state transitions. significance is the state transition Input: when to change state Output: how to change state Inputs: Control Outputs: Brake, Gas

Finite State Machine (FSM) Mealy FSM Execution Sequence Wait a prescribed amount of time (optional) Read inputs Perform output, which depends on the input and the current state Change state, which depends on the input and the current state Go back to 1. and repeat

Finite State Machine (FSM)

FSM Implementation Data Structure embodies the FSM Linked Structure multiple identically-structured nodes statically-allocated fixed-size linked structures one-to-one mapping FSM state graph and linked structure one structure for each state Linked Structure pointer (or link) to other nodes (define next states) Table structure indices to other nodes (define next states)

Traffic Light Control PE1=0, PE0=0 means no cars exist on either road PE1=0, PE0=1 means there are cars on the East road PE1=1, PE0=0 means there are cars on the North road PE1=1, PE0=1 means there are cars on both roads goN, PB5-0 = 100001 makes it green on North and red on East waitN, PB5-0 = 100010 makes it yellow on North and red on East goE, PB5-0 = 001100 makes it red on North and green on East waitE, PB5-0 = 010100 makes it red on North and yellow on East

Traffic Light Control

Linked Data Structure in C const struct State { uint32_t Out; uint32_t Time; // 10 ms units uint32_t Next[4]; // list of next states }; typedef const struct State STyp; #define goN 0 #define waitN 1 #define goE 2 #define waitE 3 STyp FSM[4] = { {0x21,3000,{goN,waitN,goN,waitN}}, {0x22, 500,{goE,goE,goE,goE}}, {0x0C,3000,{goE,goE,waitE,waitE}}, {0x14, 500,{goN,goN,goN,goN}}

FSM Engine in C (Moore) void main(void) { uint32 CS; // index of current state uint32_t Input; // initialize ports and timer … CS = goN; // start state while(1) { LIGHT = FSM[CS].Out; // set lights SysTick_Wait10ms(FSM[CS].Time); Input = SENSOR; // read sensors CS = FSM[CS].Next[Input]; }