Other Parts Discussed in Thread: TMS320F28035
We are using CPU timer 2 as a sort of external pulse counter.
So far we have used the following code to configure CPU timer 2:
EALLOW;
SysCtrlRegs.PCLKCR3.bit.CPUTIMER2ENCLK = 1; //Enable CPU timer 2
SysCtrlRegs.CLKCTL.bit.TMR2CLKSRCSEL = 1; //Set the input clock of timer 2 to use the external pin
SysCtrlRegs.CLKCTL.bit.TMR2CLKPRESCALE = 0; //Set the prescaler of the input clock source to /1
SysCtrlRegs.XCLK.bit.XCLKINSEL = 1; //Set the external clock source pin as GPIO19
EDIS;
Everything works fine except on a power-on reset, the first 6 pulses from GPIO19 do not cause CpuTimer2Regs.TIM to count down. After the 6th pulse, the CpuTimer counts down normally.
It seems that this problem is time-independant and frequency-independant. I could wait several minutes after power up and the first 6 pulses would be lost no matter what. I could also send pulses several seconds apart and they would also be lost until the 7th pulse.
I another thing that I have tried is to set TMR2CLKSRCSEL = 0 (SYSCLKOUT), wait a few microseconds, then switch back to TMR2CLKSRCSEL = 1. Using the debugger, I observed that CpuTimer2Regs.TIM had decremented while the clock source was SYSCLKOUT, but right after switching to the external clock source, the first 6 pulses were lost again.
Any idea what I am doing wrong?