Quantcast
Viewing all articles
Browse latest Browse all 4909

SDK • RP2350: systick gotcha - FYI

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)

If I do this on the RP2350 the code nearly always returns immediately. In other words, despite systick_hw->cvr being volatile it is not being seen as set before the while loop tests the value.

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 matherp — Sat Aug 31, 2024 5:42 pm



Viewing all articles
Browse latest Browse all 4909

Trending Articles