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

SDK • Re: RP2350: systick gotcha - FYI

$
0
0
I am still trying to figure out if it worked like this without setting the RVR, by real counting (it shouldn't), or just by mere luck (like running random code as a delay). WS2812 timings are roughly around 400 ns or 30-40 processor clock cycles. Also, the Arm's SysTick implementation is the same on M0+ and M33.
I use systick on the rp2040 to time short periods e.g. WS2812 timings
On the RP2040 and on every STM32 I've tried the following works:

Code:

#define shortpause(a){systick_hw->cvr=0;while(systick_hw->cvr>a){};}
so if I want a pause of say 100 clock cycles I call shortpause(0xFFFFFF - 100 + calling fudge factor)
...
To fix this I have used

Code:

#define shortpause(a){systick_hw->cvr=0;asm("NOP");asm("NOP");asm("NOP");asm("NOP");asm("NOP");while(systick_hw->cvr>a){};}
and it is now reliable

Statistics: Posted by gmx — Wed Sep 04, 2024 9:47 pm



Viewing all articles
Browse latest Browse all 5067

Trending Articles