I program a spare DMA Timer to free-run at an appropriate rate, and use that for all "real time" measurements. Having it run at 1MHz is very convenient for the software as it doesn't involve any "human time to clock tick" conversions.
The following assumes that the timer is running:
/* * Define an architecture-neutral microsecond function. For * the mcf5329 CPU we're suing DMA Timer 1 to count * microseconds. */#define DEBUG_US() (MCF_DTIM1_DTCN) ... uint32_t nTimer = DEBUG_US(); ... Do whatever ... nTimer = DEBUG_US() - nTimer; printf("Whatever took %dus\n", nTimer);
Tom