I\'m trying to implement a microsecond delay in a bare metal arm environment( LPC1768 ) / GCC. I\'ve seen the examples that use the SysTimer to generate an interrupt that then d
You can use SYSTICK inside ARM processor for that. Just program it to count each 1uS, or less if you have enough clock speed, and do-while a loop till your delay value expires. Like this:
void WaitUs(int us) {
unsigned int cnt;
while(us-- >0) {
cnt = STK_VAL; // get systick counter, ticking each 500nS
while( (STK_VAL-cnt) < 2); // repeat till 2 ticks
}
}
Bear in mind that this is an example, you'll need to adjust it for counter roll-over among other things.