Part Number: TMS320F280049C
Tool/software: Code Composer Studio
Dear support team,
I am trying to implement a simple test function for Xtal frequency drift with the help of the timer2 and OSC2 as described in the TI safety pack, file: STL_oscillator_test.c. I would like to perform this test in the beginning of the boot file, so I am doing this in assembly, together with other basic checks like register testing, etc.
I am facing an issue, hope is something easy to solve. The routine is attached below. Before this routine I disable watchdog, test CPU registers, configure couple of GPIO, and set PLL to generate a SYSCLK of 100Mhz out of OSC2.
The issue is: if I place a breakpoint on the BREAKPOINT1 position (please check code below), the TIM count is as expected: 0xFFEB (It went from 0xFFFF to 0xFFEB) that is 20 counts. Since XTAL used is 20Mhz, it results 5 times lower than actual PLL OSC2 running at 100Mhz. And the timer has a div /2 set on pre-scaler.
But if I DISABLE BREAKPOINT1, and ENABLE breakpoint on the BREAKPOINT2 position, the TIM count is 0xFF78, which is far from the 20 counts expected.
Funny thing is that if I comment out the NOP and the next RPT #TEST_COUNT_NOPs || NOP line, no matter where I place the breakpoint, it always work as expected (count of 0xFFF0 which is 15 counts as expected). This lead me to think that there is maybe an issue with the pipeline that I am not understanding....
Thanks in advance for your kindly help!
Regards,
Alberto Peyro
This is my test routine:
__CPUREG_SYS .usect "CpuSysRegsFile",0 TMR2CLKCTL .set 0x7C
__TIMER2_REGS .usect "CpuTimer2RegsFile",0
TEST_COUNT_NOPs .set 49
TIM .set 0x00 PRD .set 0x02 TCR .set 0x04 TPR .set 0x06 TPRH .set 0x07 .section .text ;******************************** ;******************************** ;CHECK RELATIVE XTAL FREQUENCY ;WITH TIMER2 _Xtal_Clock_Drift_Test: MOVL XAR4,#__TIMER2_REGS MOVL XAR5,#(__CPUREG_SYS+TMR2CLKCTL) ;configure timer 2 to perform test MOV *+XAR4[TPR],#1 MOV *+XAR4[TPRH],#0 MOV *+XAR4[PRD],#0xFFFF MOV *+XAR4[PRD+1],#0xFFFF MOV *+XAR4[TCR],#0x0000 OR *+XAR4[TCR],#0x0020 ; reload timer NOP ;set XTAL clock to feed the timer2 EALLOW MOV *XAR5,#0x0000 OR *XAR5,#0x0003 ;select Xtal as input clock for timer2 NOP EDIS ;fire timer DINT ;disable maskable interrupts AND *+XAR4[TCR],#~0xffef ;wait some cycles RPT #TEST_COUNT_NOPs || NOP RPT #TEST_COUNT_NOPs || NOP RPT #TEST_COUNT_NOPs || NOP NOP RPT #TEST_COUNT_NOPs || NOP ;stop timer MOV *+XAR4[TCR],#0x0000 NOP ; <---------- BREAKPOINT 1 ;check if timer overflowed MOVL ACC,*+XAR4[TCR] OR ACC,#1 ; <-------- BREAKPOINT 2
