[Solved] USB serial affecting ADC interrupts?
Hello!
Teensy 3.2 running at 96Mhz, ADC in free running mode. Oversample count 1, conversion speed VERY_LOW_SPEED, sampling speed VERY_LOW_SPEED, resulting in a 75KHz math calculation.
Using a ring buffer in my ADC ISR.
Trying with both ADC library, and bypassing ADC library.
Frequency 75000 without USB streaming
When no USB data is occuring, it runs at almost exactly 75KHz (75000 samples a second, +/- 0.5)
Frequency 74950-74990 with USB serial streaming at 1.5 Mbits/second
Frequency 74600-74750 with USB serial streaming at 3 Mbits/second
However, when I stream USB data, the ADC frequency falls gradually, the more data I try to stream out of the USB port (using the Serial library)
Upon further diagnosis using micros(), I notice sometimes the time interval between two values exceeds 2/75000ths of a second -- which means missed ADC samples! So it appears that USB transmissions somehow block the ADC ISR for more than 2/75000th of a second. These interrupt-blockings seems to happen roughly once every 64 bytes written to the USB port, corresponding to the USB packet transmission.
This problem does not happen at 18.75Khz (oversample count 4) but I do see lots of jitter in time between interrupts coinciding at the same intervals, but not severe enough to reach 2/18750ths of a second.
Hello!
Teensy 3.2 running at 96Mhz, ADC in free running mode. Oversample count 1, conversion speed VERY_LOW_SPEED, sampling speed VERY_LOW_SPEED, resulting in a 75KHz math calculation.
Using a ring buffer in my ADC ISR.
Trying with both ADC library, and bypassing ADC library.
Frequency 75000 without USB streaming
When no USB data is occuring, it runs at almost exactly 75KHz (75000 samples a second, +/- 0.5)
Frequency 74950-74990 with USB serial streaming at 1.5 Mbits/second
Frequency 74600-74750 with USB serial streaming at 3 Mbits/second
However, when I stream USB data, the ADC frequency falls gradually, the more data I try to stream out of the USB port (using the Serial library)
Upon further diagnosis using micros(), I notice sometimes the time interval between two values exceeds 2/75000ths of a second -- which means missed ADC samples! So it appears that USB transmissions somehow block the ADC ISR for more than 2/75000th of a second. These interrupt-blockings seems to happen roughly once every 64 bytes written to the USB port, corresponding to the USB packet transmission.
This problem does not happen at 18.75Khz (oversample count 4) but I do see lots of jitter in time between interrupts coinciding at the same intervals, but not severe enough to reach 2/18750ths of a second.
Last edited: