Just re-posted with the correct tag. ---------- Forwarded message ---------- From: Joe Wronski Date: 18 April 2013 07:59 Subject: Re: PIC32 multitasking To: "Microcontroller discussion list - Public." On 4/18/2013 2:34 AM, veegee wrote: > Was doing some searching on better ways to multitask on the PIC32 short > of FreeRTOS, after believing that my state machine was too crude. Here > are a couple of interesting things I found: > > https://github.com/andersm/TNKernel-PIC32 is a port of TNKernel (small > RTOS written in C) to the PIC32. I found it when searching for a short C > code snippet for MIPS32 context switching for cooperative OS. If > anything, the context-switching code in there is quite useful. > > http://dunkels.com/adam/pt/ Protothreads is an extremely tiny > header-only C macro library which masks state machines behind simple > macros. Turns out state machines aren't a bad idea, and this is actually > a "thing". I decided to convert my hard-coded state machines to use this > library and saved a lot of lines of code. Having never worked with any RTOS due to ROM and RAM limitations, I find Protothreads fascinating. Where my cow-orkers and I had hand crafted state machines which closely resembled the Protothreads expanded macros, using PT would have made the code more readable and maintainable. I had never considered using the __LINE__ macro for anything other than compiler error and warning info. And I never realized that you could put the case : argument of a switch within a while loop (Duff's Device). Joe W -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist --=20 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .