On Tue, 1 Feb 2005 07:55:20 +0100, Wouter van Ooijen wrote: > > while (TRUE) > > { > > if (DO_IT_NOW) > > pid_calculations(); > > code_a(); > > code_b(); > > code_c(); > > code_d(); > > } > > > > since the DO_IT_NOW flag could be set at any time by > > the interrupt (or the TMR1IF flag), the PID code could run > > immediately, or after all the other routines, or... > > But that's because you want your code to do too much. If sum of your pid > + code_a + code_b etc execuation times takes more time than the timer > interval you should not execute all code_a + code_b + code_c + code_d, > but for intsnace only one of them (round robin fashion), or transform > one or more to a state machine that speads the execution time over more > than one call. Now you're saying I need to change the requirements. That's something you need to take up with my employer. Bill -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist