软件在运行时突然会跑到Illegal Instruction Interrupt!
使用的是CCS3.3,CGT V4.1.3和V5.2.15都试过了,使用的是L2优化。软件为前后台结构。
进入到非法指令中断后,读返回地址每次都不一样,返回地址对应的函数并无特别之处,有何高招啊各位?
ZhangLi1:Q: What causes an illegal (ITRAP) interrupt?
An invalid instruction is decoded (this includes invalid addressing modes).
The opcode value 0x0000 is decoded. This opcode corresponds to the ITRAP0 instruction.
The opcode value 0xFFFF is decoded. This opcode corresponds to the ITRAP1 instruction.
A 32-bit operation attempts to use the @SP register addressing mode.
Address mode setting AMODE=1 and PAGE0=1which is an illegal combination.
以上,我的代码除了BOOT时的跳转指令外,其余是纯C,应该不会触碰到以上几点吧(除非编译器)
Q: How can I debug an ITRAP?
An ITRAP is often a sign of stack overflowing or a buffer overflowing. To quickly see if it is the stack you can fill the region with a known value and then run the application. By the addresses written to you will be able to see how big the stack grew.
This application note has a method for using on-chip resources to detect when a stack overflow occurs: Online Stack Overflow Detection on the TMS320C28x DSP (spra820).
关于以上两点的堆栈检查,堆栈开辟了0x400空间,没有检查实际到底会占用多大堆栈,但试过开辟0x500堆栈空间也会进入illegal instruction interrupt
Make sure code isn't getting too close to the end of a valid memory block (which is followed by invalid memory). This is explained in the device errata.
似乎也没有,在RAM中运行的代码划了0x2600空间,使用0x02573; Flash应该没有太多问题吧。
Make sure the CPU is not pre-fetching into the code security password location.
如何make sure?
Insert a return instruction into the ISR. Set a breakpoint on this instruction and then step to see where the code came from.
Another option is to look at the stack. When you take an illegal instruction trap, registers are automatically pushed on the stack, including the return address. By looking at the return address value on the stack, you can find out where the ITRAP occurred.
可以在illegal interrrupt中读取返回地址,但是每次都不一样。
–另外,请检查下时钟、电源、复位等等外围电路。
批量生产的板子,使用有源时钟和专用复位芯片,电源没有使用TPSxxx,简单的ASM1117-3.3/1.8V供电,DSP为F2808