hi guys- just a quick question.
i want in my program to run 2 separate loops - a control loop - running at 120Hz with a runtime of ~6ms, and a communications loop - running at 25Hz with a runtime of ~3ms.
to do this i set up 2 timers (using the Atmega2560) to run at these speeds... now here comes the tricky part- i cant run the loops inside the ISR since the arduino framework doesnt allow nested interrupts which is required to read the digital sensors and receive incoming serial data and PPM data... the only solution i found was to raise flags in the ISR's and then run the loops inside the main Loop... this causes some problems such as inconsistent run frequencies (problematic for the PID).
how can i design the infrastructure of my program so that i run these loop at fixed constant speeds? ( please elaborate with code, i'm no AVR expert...)