How to create a delay in microseconds?

Hi Guys

Is there an elegant way of creating a delay of say 20-50us? I can use the MS_TIMER for millisecond delays but wanted to see if there was anything better than just having a dummy loop going around to create a delay in program advancement.

I’m using a RCM6700 and 10.72E


It depends on what you need the delay for.

Does it need to be precise, or is it just a minimal delay before continuing with some action?

Do you want to be doing something else while waiting for the delay to expire?

The simplest solution is to calculate the duration of an assembly loop over some “nop” opcodes, perhaps with a calculation so you can adjust it for different us delays.

None of the code in Dynamic C related to microsecond delays applies to the Rabbit 6000, so you’ll be on your own to figure out the necessary timing to get the result you’re looking for. I’d recommend toggling an output pin before and after the delay code and measuring the pulse with a scope or logic probe.

It’s also possible that Timer B or Timer C could be useful. I know they can pulse output pins with durations in the microsecond range, but you might be able to connect an ISR that sets a global flag when the delay has passed.

Thanks Tom. That’s kind of what I figured. I don’t need to be doing anything. I just need the program to halt for a little while (<1ms) to give some time for external hardware to respond.

I thought I was missing something obvious. I’ll try what you suggest