Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4960

General • Re: RP2040 counter error.

$
0
0
When using interrupts, you will always get some jitter; at low frequencies, this may be too small to notice, but at higher frequencies it will become significant. So the output frequency over a long time will be correct, but each individual output pulse will be slightly shorter or longer than it should be.

This isn't really fixable; all you can do is try to minimise it. One way would be to trigger a DMA cycle instead of an interrupt; there is an example of PWM triggering DMA at https://iosoft.blog/picofreq This code will need some modifications to do what you want (i.e. creating 2 DMA descriptors chained together, one to set the output, and the other to clear it), but initiating a DMA cycle is a lot faster than an interrupt, so you should get a much better output.

Alternatively, just use hardware; a simple flip-flop would do the job really well.

Statistics: Posted by jayben — Wed Jan 22, 2025 9:56 am



Viewing all articles
Browse latest Browse all 4960

Trending Articles