TMS320F28379D: 程序使用flash烧录时卡死在DefaultISR.c程序中

Part Number: TMS320F28379D

经过单步调试发现是在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;
}
}

请问是什么原因

  • 已经收到了您的案例,调查需要些时间,感谢您的耐心等待。

  • 是进入了DefaultISR.c中的非法中断interrupt void ILLEGAL_ISR(void),然后调试的时候发现是在以上程序里一直循环出不来

  • 您好,

    既然你可以调试代码,你如何调试for循环,并告诉我为什么它不退出循环.

    例如,检查什么是sizeof(GpioCtrlRegs)/2,如果在闪存程序中正确设置/初始化了变量等等?

  • 您好,

    这是被触发的非法指令ISR, ITRAP吗?

    如果是,请按照步骤查找ITRAP的根本原因,ISR中可能存在无限的for循环,这是它永远循环的地方。

    https://software-dl.ti.com/C2000/docs/c28x_interrupt_faq/html/index.html

    The ITRAP Interrupt

    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.

    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).

    • 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的例程解决了这个问题,也许是我的环境配置有问题

  • 您好,

    感谢您的反馈,由于问题已解决,此例程关闭。

x 出现错误。请重试或与管理员联系。