I’m trying to run some servos using the PWM features of ATmega32 hardware timers, producing a 1-2ms pulse with a 1/128ms resolution. My capture/compare interrupt code works as a stand-alone, but when I integrate it with freeRTOS, the signal jitters by about 30us which causes the servos to shake.
I’ve tried modifying the tick code to use timer2 instead of timer1, I’ve tried using naked interrupts, using enter/exit critical and also running the code as a plain hardware interrupt rather than using the interrupt to resume the task but nothing seems to work.
FreeRTOS is running the ATmega32’s 8MHz internal clock with a tick rate of 1000. Is the interrupt latency of the ATmega32 on freeRTOS too much for use with servos, or am I doing something wrong here?