Other Parts Discussed in Thread: CONTROLSUITE
Tool/software: Code Composer Studio
Hi, since 4 years we use the really helpful source files for configuration of C2000 hardware.
e.G. Timer configuration, here this soure code (see below), which is delivered with several tools like ControlSuite.
I wonder, if this line is correct to get the exact wished time:
temp = (long) (Freq * Period);
Could it be possible, that there is than a difference of one cycle?
And the correct code have to be this:
temp = (long) (Freq * Period) -1;
????
br Ralf
void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period)
{
Uint32 temp;
// Initialize timer period:
Timer->CPUFreqInMHz = Freq;
Timer->PeriodInUSec = Period;
temp = (long) (Freq * Period);
Timer->RegsAddr->PRD.all = temp;
// Set pre-scale counter to divide by 1 (SYSCLKOUT):
Timer->RegsAddr->TPR.all = 0;
Timer->RegsAddr->TPRH.all = 0;
// Initialize timer control register:
Timer->RegsAddr->TCR.bit.TSS = 1; // 1 = Stop timer, 0 = Start/Restart Timer
Timer->RegsAddr->TCR.bit.TRB = 1; // 1 = reload timer
Timer->RegsAddr->TCR.bit.SOFT = 1;
Timer->RegsAddr->TCR.bit.FREE = 1; // Timer Free Run
Timer->RegsAddr->TCR.bit.TIE = 1; // 0 = Disable/ 1 = Enable Timer Interrupt
// Reset interrupt counter:
Timer->InterruptCount = 0;
}