EETimes

Embedded Systems September 2000 Vol13_10

Issue link: http://dc.ee.ubm-us.com/i/71837

Contents of this Issue

Navigation

Page 162 of 229

This piece of code will execute 100 times to check 10,000 bytes of RAM. We control how often the memory check is done using the usual execu- tion counte r and reload value tech- nique. Another va riation of the same idea is shown in Listing 8. The task is doing noth ing until somebody sets the WinTaskState to any non-id le sta te. Up to fo ur fo llowing itera tions will then upda te relevant po rtions of informa- tion in the window. For example, tore- paint the entire window, we would set Wi nTaskState to WIN_TASK._CONST, which will update all the constant informa tio n, all variable informa tion, and al l graphics and animatio ns in the window. Afte r th is u pdate the window upda te task will become idle again unti l th e next trigger via a Wi nTaskState. Conven iently, if we only want to upda te the an ima tions, we can set the WinTaskState to WIN_TASK_ANI- MATIONS (in tl1is case, we will not re- paint the constants, variables, and stat- ic graphics on the screen ). Figure 2 shows the LCD upda te task's ta te tran- sition diagram. Software timers The software time rs add a "real" mul- ti tasking be havior to our system. There are hundreds of actions that require events to happen at a ftxed time once or pe riod ically. Some exam- ples a re: • A blinking cursor • An output tha t needs to be pe riod- ically switched on / off • The need to show a user message tl1at will disappear or change after a ftxed period • The need to ligh t up the keypad or the LCD and turn it off after a peri- od of inactivi ty • A sho rt reset pulse to the printe r • A fl ash ing lamp } Do we really want to dedica te pe ri- od ic tasks to these li ttle, yet important, functio ns? Most of these will also require exact timing, ma king our 10ms interrupt wo rk very hard. Our } } •I } EXPIRED_TIME~BUF; The software timers add a "real" multitaslrd)) word TIIR_Start(word timer_handle, word timeout, dword parameter); word TMR_Stop(word timer_handle); LlmNG 11 Software timer task EXPIRED_TIME~EVENT_TYPE •Timer; void ~rocess(void) { if ((Timer = ~GetEvent()) != INVALID_TIMER) { if TimeoutHandler != M.JLU { II call the user timeout function indirectly .. Timer->TimeoutHandler(Timer->ID, Timer->Parameter); · . . Embedded Systems Programming SEPTEMBER 2000 161

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems September 2000 Vol13_10