经过单步调试发现是在Gpio.c文件中的init函数中的循环里卡住了,如下
for (regOffset = 0; regOffset < sizeof(GpioCtrlRegs)/2; regOffset++)
{
//
//Hack to avoid enabling pull-ups on all pins. GPyPUD is offset
//0x0C in each register group of 0x40 words. Since this is a
//32-bit pointer, the addresses must be divided by 2.
//
if (regOffset % (0x40/2) != (0x0C/2))
{
gpioBaseAddr[regOffset] = 0x00000000;
}
}
请问是什么原因
您好,
这是被触发的非法指令ISR, ITRAP吗?
如果是,请按照步骤查找ITRAP的根本原因,ISR中可能存在无限的for循环,这是它永远循环的地方。
https://software-dl.ti.com/C2000/docs/c28x_interrupt_faq/html/index.html
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.
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).
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.
Make sure that if any code is being loaded into flash and run from RAM that it is properly copied to RAM before the function is called.
Make sure the CPU is not pre-fetching into the code security password location.
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.
感谢你的回复 这是ti官方的Gpio.c文件,我也不知道sizeof(GpioCtrlRegs)/2是什么以及为什么会卡在这里,好在我通过直接引用ti的例程解决了这个问题,也许是我的环境配置有问题