I have used a state machine based co-operative multitasking approach in man= y systems. The main code is a loop calling each task state machine, which i= s a large switch statement, usually. Finding the right size of block and un= rolling loops can get tedious and it can look messy but it does work well. = I have had such systems deal with timers and comms, the interrupt handles j= ust raise flags and the code in the state machines handles things.=20 On 2013-04-18, at 11:20 PM, veegee wrote: > On 2013-04-18 10:59 AM, Joe Wronski wrote: >> Having never worked with any RTOS due to ROM and RAM limitations, I find= =20 >> Protothreads fascinating. Where my cow-orkers and I had hand crafted= =20 >> state machines which closely resembled the Protothreads expanded macros,= =20 >> using PT would have made the code more readable and maintainable. I had= =20 >> never considered using the __LINE__ macro for anything other than=20 >> compiler error and warning info. And I never realized that you could=20 >> put the case : argument of a switch within a while loop (Duff's Device). >=20 > Yup, C switches behave somewhat like labels. The cases are valid > anywhere within the switch. >=20 > --=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 --=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 .