I have a project that outputs a series of values to DACs with a precise timing interval. The problem is that sometimes there is a delay longer than expected between the system timer interrupt in which the DAC values are updated. This leads to jitter in the output. I need help figuring out what is causing this delay. The only other user code running than the timer is handling of incoming USB packets containing the data to be output.
Things I have tried:
- Decreasing the priority of every single interrupt other than the timer
- Disabling any kind of sleep mode that might require time to wake up from
- Decreasing the USB packet size to make them faster to process (though because of their interrupts having lower priority it shouldn't interfere with the timer anyway)
But nothing has worked so far.
The MCU is an Atmel ATSAM4S2B (32-bit arm cortex-m4)
EDIT: I found the problem, it was the interrupt priorities. I set the priorities at bootup, however the CMSIS library SysTick_Config() function actually resets the priority for the systick every time it is called, so I had to manually correct the priority every time I called this.