Thursday, June 29, 2006

Tiny Threads - Tiny Multitasking Threads for Microcontrollers

by: Regulus Berdin
Limitations:
  • Maximum 254 lines per thread.
  • Thread context switching will not work within a switch block.
Usage example:
     TT_DEF(1)
{
TT_BEGIN(1);
while (1)
{
...
TT_SWITCH(1);
...
...
TT_WAIT_UNTIL(1,keypress);
}
TT_END(1);
}

TT_DEF(LED_TASK)
{
TT_BEGIN(LED_TASK);
while (1)
{
LedOn();
delay=DELAY_1_SECOND;
TT_WAIT_UNTIL(LED_TASK,delay==0);
LedOff();
delay=DELAY_1_SECOND;
TT_WAIT_UNTIL(LED_TASK,delay==0);
}
TT_END(LED_TASK);
}

void main(void)
{
...
...
while(1)
{
TT_SCHED(1);
TT_SCHED(LED_TASK);
}
}
Visit Site

1 Comments:

Blogger Bobo said...

Hello,

You published this code and a interrupt driven routine for serial on the http://www.microchipc.com website. Can you tell me how the later functions? I want to adapt it so I can use it for SPI. The round FIFO idea is great, but, for me, it hangs at the while conditions. Can you tell me what is the logic behind it?
Thank you.

10:48 AM  

Post a Comment

<< Home