Other Parts Discussed in Thread: C2000WARE
Hi,
I'm observing a weird behavior. My code is executed from RAM. The very first time it runs, the code ends up in an invalid location. However, afterwards it works perfectly every time. I initially thought it could be related to an initialization, but I got it to the point where I can replicate the behavior by just commenting / un-commenting one line: the interrupt enable.That is, I comment the interrupt enable, compile, run, the code behaves correctly. I un-comment it, the first time it fails, then I reset it (using CCS), and it works properly. As you can see in the code, I purposely removed all code from the interruption
So, here's the related code:
__interrupt void TimerInterrupt_vector(void) {
//void for testing
}
void TimerInt_Init(void) {
/*First, disable interrupts...*/
DINT;
/*clear any interrupt flag*/
__asm(" AND IER, #0");
__asm(" AND IFR, #0");
EALLOW();
pieVectTable.TIMER1_INT = &TimerInterrupt_vector;
EDIS();
/*Stop timer*/
reg_CpuTimer1.TCR.bit.TSS = 1u;
/* Set the timer registers with the initial and reset values */
reg_CpuTimer1.PRD.all = TIMER_PERIOD_40us;
/*Since the period is too short, we don't need a prescaler*/
reg_CpuTimer1.TPR.bit.TDDR = 0;
reg_CpuTimer1.TPRH.bit.TDDRH = 0;
/*Reset the timer (loads the period into the timer register)*/
reg_CpuTimer1.TCR.bit.TRB = 1u;
/*Enable interrupt*/
reg_CpuTimer1.TCR.bit.TIE = 1u;
/*Start timer*/
reg_CpuTimer1.TCR.bit.TSS = 0u;
ENABLE_T1_INT();
EINT();
ERTM();
}
I have verified what you might expect: that the vector is properly set, that the bits are correct, etc. I noticed, though, that the invalid address where I end up was somehow pushed into the stack (I verified this with a breakpoint in the invalid address, then checking the stack).
Am I missing one configuration bit or something that could explain this strange behavior?