| ??? 01/20/03 11:27 Read: times |
#36835 - RE: can 8051 do multi tasking? |
The simplest solution is to setup a timer that producess an interrupt at an interval suitable for your application. You create a main loop where you handle all your regulat stuff, let's say input and output. You also check if the timer interrupt has occurred, and , based on that, you handle all relevant time-related stuff in a separate part of your main-loop. You can create time granulation by adding (a) software prescaler(s). As an exemple take the following speudo-code that handles one action every 10 ms and one every 50 ms. You could expand it to suit any timing and any number of timed functions:
. . Setup10msTimer(); Prescale=0; . . while(1) // main program loop { if (TimerInt) // Has an interrupt occurred? { Do10msThing(); if (Prescale>4) // >= 50 ms ? { Do50msThing(); Prescale=0; } TimerInt=0; // Wait for next 10 ms } } _interrupt 10msTimer() { TimerInt=1; Prescale++; } |
| Topic | Author | Date |
| can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
| RE: can 8051 do multi tasking? | 01/01/70 00:00 | |
RE: can 8051 do multi tasking? | 01/01/70 00:00 |



