DMA timers are perfect for sub-microsecond delays. They can be configured as 32-bit naturally overflowing timers running at CPU frequency:
#include "mcf522regs.h"
#define DTIM_NUM 1
void
timer_init(void)
{
DTIM_DTMR(DTIM_NUM) = DTMR_CLK_DIV1 | DTMR_RST;
}
void
timer_delay(unsigned int ticks)
{
unsigned int start, diff;
start = DTIM_DTCN(DTIM_NUM);
do
{
diff = DTIM_DTCN(DTIM_NUM) - start;
}
while (diff <= ticks);
}
DMA timers are perfect for sub-microsecond delays. They can be configured as 32-bit naturally overflowing timers running at CPU frequency:
#include "mcf522regs.h"
#define DTIM_NUM 1
void
timer_init(void)
{
DTIM_DTMR(DTIM_NUM) = DTMR_CLK_DIV1 | DTMR_RST;
}
void
timer_delay(unsigned int ticks)
{
unsigned int start, diff;
start = DTIM_DTCN(DTIM_NUM);
do
{
diff = DTIM_DTCN(DTIM_NUM) - start;
}
while (diff <= ticks);
}