Motorola Coldfire delay() function

Joel Sherrill joel.sherrill at
Wed Dec 3 14:08:29 UTC 2003

Charles Steaderman wrote:
> I have a custom board based upon the mcf5206e Coldfire processor. I 
> based my custom bsp upon the excellent mcf5206elite bsp. I would like to 
> use a delay() function to signal an error via leds if a fatal error 
> occurs. There is a delay(microseconds) macro included with the 
> mcf5206elite bsp, but the assembly instructions that it uses are for a 
> full-blown M68K, not the Coldfire processor. The delay function is as 
> follows:
> #define delay( microseconds ) \
>  { register rtems_unsigned32 _delay=(microseconds); \
>    register rtems_unsigned32 _tmp=123; \
>    asm volatile( "0: \
>                     nbcd      %0 ; \
>                     nbcd      %0 ; \
>                     dbf       %1,0b" \
>                  : "=d" (_tmp), "=d" (_delay) \
>                  : "0"  (_tmp), "1"  (_delay) ); \
>  }
> Does anyone know Coldfire assembly well enough to supply suitable, 
> replacement instructions for "nbcd" and "dbf"?

Well since no one else is wading in...

This should be renamed to rtems_bsp_delay().  There was a sweep in Sept
2001 to rename them all to avoid such a common name.

On to how to implement it... it does not have to be an instruction loop.
It could poll a counter/timer register or whatever.  It could inline a
handful of NOPS or anything else as long as it kills time in microsecond

> Thanks,
> - Charlie

Joel Sherrill, Ph.D.             Director of Research & Development
joel at                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

More information about the users mailing list