Download Embedded Multitasking with small - innovated
Transcript
96 Chapter 2 The final construct to examine in an execution-indexed state machine is the CALL/RETURN. Now, the question arises, why do designers need a subroutine construct in state machines? What possible use is it? Well, let’s take the example of a state machine that has to generate two different delays. State machine delays are typically implemented by repeatedly calling a do-nothing state, and then returning to an active state. For example, the following is a typical state machine delay: CASE 3: Code Snippet 2.25 CASE 4: Counter = 6; State_var = 4; Break; IF (Counter == 0) THEN State_var = 5; Counter = Counter – 1; Break; CASE 5: This routine will wait in state 4 a total of six times before moving on to state 5. If we want to create two different delays, or use the same delay twice, we would have to create two different wait states. However, if we build the delay as a subroutine state, implementing both the CALL and RETURN, we can use the same state over and over, saving program memory. For example: CASE 3: Code Snippet 2.26 Counter = 6; State_var = 20; Back_var = 4 Break; | | | | CASE 12: Counter = 10; State_var = 20; Back_var = 13 Break; | | | | CASE 20: IF (Counter == 0) THEN State_var = Back_var; Counter = Counter – 1; Break;
Related documents
mgr-a7 manuale di avvio rapido
Audiocodes 320HD Admin Guide
Unit Verification: The CARA Experience
User Manual - Skip
OS-9 Porting Guide
Solar Portable Water Purification TMS Survivor 300 User Manual E
User`s Manual - HDTV Solutions
DX-1220 - Beglec
ATOM1 : MC68360 ATM Microcode User`s Manual
PETracer/Trainer EML User Manual
XFP USER MANUAL 2/8
Guide de préparation à L`Etape du Tour 2015