Hi,
I am facing a weird issue with launchpad of TMS570LC4357.
When JTAG is connected, the code works fine. I can do free run, pause, reset, free run again or step-over/step-in etc. As soon as I do a power cycle (disconnect USB and reconnect), the code gets stuck in data abort and does not execute further. (I found this by reconnecting the target and just loading symbols).
The main function of my code looks like this:
void main(void)
{
/* Initialise the drivers */
initDrivers();
/* Initialise the application */
initApp();
/* Initialise the scheduler */
initScheduler();
while (1)
{
}
}
The initDrivers() function is something like this:
void initDrivers()
{
/* Initialise discrete */
initDiscretes();
/* Configure CAN */
initCan(&ConfigAddr);
/* Configure SPI */
initSpi();
/* Enable the watchdog timer */
enableWatchdog();
}
When I reconnect the JTAG with just loading symbols, WITHOUT programming the flash again, I see that, the formal parameter of initCan() function is not initialised with the address of "ConfigAddr" passed as actual parameter. And I see that particular memory location and few other locations are not writable even in memory window directly or using expressions window. As soon as I reprogram the same code, it starts working perfectly with JTAG connected, and behaves weirdly again when power cycled.
BUT there is a twist:
If I move the statement "enableWatchdog();" from initDrivers() function to the main() function, just after the call to initDrivers() function like this:
void main(void)
{
/* Initialise the drivers */
initDrivers();
enableWatchdog();
/* rest of the code */
}
(which is essentially the same execution order, no difference), everything works seamlessly, with as many power cycles as we want.
The content of enableWatchdog() function is:
void enableWatchdog()
{
RTI->RTIDWDCTRL = DWD_ENA_KEY;
}
I have faced this problem few times, and it has seemed to disappear with some illogical changes in code like the above one. I have run out of ideas to find root cause of the problem. Could you please help?
Thank you.
