Other Parts Discussed in Thread: SYSCONFIG, C2000WARE
Tool/software:
Good afternoon!
Please help me understanding:
I need a milliseconds delay routine for my project using CM core.
When I use DEVICE_DELAY_US(milliSeconds * 1000), the result seems to be reasonable.
But when I am trying to use cpu timer to have more accurate delays, like this:
CPUTimer_setPeriod(CPUTIMER2_BASE, (CM_CLK_FREQ / 1000) * milliSeconds - 1);
CPUTimer_setPreScaler(CPUTIMER2_BASE, 0);
CPUTimer_stopTimer(CPUTIMER2_BASE);
CPUTimer_reloadTimerCounter(CPUTIMER2_BASE);
CPUTimer_setEmulationMode(CPUTIMER2_BASE, CPUTIMER_EMULATIONMODE_RUNFREE);
CPUTimer_startTimer(CPUTIMER2_BASE);
CPUTimer_clearOverflowFlag(CPUTIMER2_BASE);
while(!CPUTimer_getTimerOverflowStatus(CPUTIMER2_BASE));
CPUTimer_stopTimer(CPUTIMER2_BASE);
The actual delay seems to be significantly shorter.
Where is the error?
UPDATE: I found the cause.
The SysConfig tool has an error, it ignores the CM CLK divider and alwais places the code in device.c:
//
// Set up CMCLK to use AUXPLL as the clock source and set the
// clock divider to 1.
//
SysCtl_setCMClk(SYSCTL_CMCLKOUT_DIV_1,SYSCTL_SOURCE_AUXPLL);
regardless of the designated divider value.
So the CM core surprizingly runs at 250MHz.