Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE
Hello,
I try to use a CPU timer for DSP TMS320F28335 and there are some mistakes in my calculation.
The processing and the writing are always the same but the timer counter can pass from 1500000 to 1120000
as from 1500000 to 10000 and it is not really good for me. So I would like to ask you if my method to
count the time of Processing+Writing is good or does something appear to be incorrect ? Thank you...
// Initialisations
Uint32 toto = 0;
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, FREQ150_MHz, 10000);
for(;;){
// Start Timer
CpuTimer0Regs.TCR.bit.TSS = 0;
Processing();
Writing();
//Stop Timer
CpuTimer0Regs.TCR.bit.TSS = 1;
// Time calculation
val_p = ((double) (CpuTimer0Regs.PRD.all - CpuTimer0Regs.TIM.all)) / ( (double) FREQ_Hz ) + 1750.0/1000000.0;
// DEBUG
toto = (double) (CpuTimer0Regs.PRD.all - CpuTimer0Regs.TIM.all);
// toto can be equal to 300000 as to 1400000, is it //normal?
// Because I want just 2ms and 1500000*6.67e-9 //(<=>CPU_RATE) = 10ms
// So 1400000 is really higher than what I want...
// This soft works fine on a computer in 0.3ms, so it would be faster on DSP...
// Waiting function
DELAY_US(1750);
/*where #define DELAY_US(A) DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) /5.0L)*/
// Reload Timer
CpuTimer0Regs.TCR.bit.TRB = 1
}
void InitCpuTimers(void){
// CPU Timer 0
// Initialize address pointers to respective timer //registers:
CpuTimer0.RegsAddr = &CpuTimer0Regs;
// Initialize timer period to maximum:
CpuTimer0Regs.PRD.all = 0xFFFFFFFF;
// Initialize pre-scale counter to divide by 1 //(SYSCLKOUT):
CpuTimer0Regs.TPR.all = 0;
CpuTimer0Regs.TPRH.all = 0;
// Make sure timer is stopped:
CpuTimer0Regs.TCR.bit.TSS = 1;
// Reload all counter register with period value:
CpuTimer0Regs.TCR.bit.TRB = 1;
// Reset interrupt counters:
CpuTimer0.InterruptCount = 0;
}