what might cause functions to periodically run more slowly? #583
-
Hi, I've been timing some functions to see how long they take (mostly just to understand how things work) and noticed some puzzling behavior. At regular intervals, about 130ms apart, the functions slow down by 25 microseconds or so. Here is a screenshot: This is in a program that uses the ADC to read two pins at 1ms intervals. I noticed that if I vary the sample rate a little then the slowdowns still happen but are less periodic. It also seems odd that the slowdown doesn't happen on the same sample for each function (even thought they are all called together in the read function) and sometimes the slowdown happens in two consecutive ticks. Do you have any ideas about what might cause this? Are there interrupt handlers enabled by default? I'm using a Raspberry Pi Pico and PlatformIO. Here is the code:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Could be USB code responding to scans from the PC. You could disable all USB (there's a define for it) and use a UART serial port. Or, you could try running your code on the 2nd core (loop->loop1). The USB is handler only runs on core0. |
Beta Was this translation helpful? Give feedback.
Could be USB code responding to scans from the PC. You could disable all USB (there's a define for it) and use a UART serial port. Or, you could try running your code on the 2nd core (loop->loop1). The USB is handler only runs on core0.