Hello,
I am programming the digital signal controller TMS320F2812. With the current project, an issue occurs that I have never had with similar source codes and settings. The program execution stops seemingly randomly. I first noticed this with the line
for (i=0;i<2500;i++) asm(" RPT #255 || NOP"); // required 5 ms delay (5.1 ms)
that is reached when a breakpoint is set there. The next line however is not reached; apparently the program gets stuck with the above line. Strangely, I have used this command in many other projects and it always worked.
A few things I have looked at to track down the problem:
With the optimization level set to 0 (instead of disabled), the above line is executed, but the program gets stuck somewhere later. I cannot find the command that does not work because a breakpoint cannot be set in the region where the execution stops, but it is most likely where there are many variable declarations.
This made me suspect that the watchdog might have to do with it. It is disabled at the beginning of the code via
EALLOW; SysCtrlRegs.WDCR=0x0068; EDIS;
Checking the value in this register before the program gets stuck, however, I found that it is 0x40. Checking back, it seems to be the case for all other programs that I have written that the watchdog control register is 0x40 and not 0x68 to which it is set. I had never noticed this and never had any problems with it either.
Also, when I change the order of the source code such that all the variable declarations are before the line
for (i=0;i<2500;i++) asm(" RPT #255 || NOP");
the program still gets stuck at this point.
Overall, it is unclear to me why the program stops. What happens in my program before an infinite loop starts are mainly configurations of peripherals and variable declarations and definitions. Many other projects with the same structure, ADC setup (in which the above line is used) and project settings have worked. What could be the problem here?
Regards,
Adrian