I am using CW 10.3 with the appropriate MQX tools installed. I have a PEMicro Multilink Universal debugger. I have a custom board using a MK20DN512ZVLL10, running MQX 3.8.1. However, my BSP is from the K20D72M and I had to do some modifications to that BSP to account for differences in the MCG registers. I also changed the code to use the internal 8pf loading caps.
My problem is that my code acts like it hits a breakpoint but there isn't a breakpoint there. Here is a timeline of what I can get to happen repeatedly.
I load code and hit the green arrow to start debugging.
Shortly after starting, the code will act as if it hit a breakpoint. From dispatch.s:
-------> bx lr
So then I hit play again. Wait a second and then it stops again in dispatch.s:
; kernel interrupt handler
-------> cpsid.n i
Now at this point I looked at the Mode Controller registers SRSH and SRSL. SRSH is 0x00, but SRSL is 0x40, indicating it was reset by an external pin. I'm not sure if that is from the reset at the start of debugging though? Anyway, if I hit play again we go back to:
; disable interrupts and clear pending flags
------> ldr r0, =0xe000e180 ; NVIC_ICER0 - Interrupt Clear-Enable Registers
ldr r1, =0xe000e280 ; NVIC_ICPR0 - Interrupt Clear-Pending Registers
At this point, if I look at the SRSH and SRSL registers, SRSH is now 0x02 for CPU lockup and SRSL is back to 0x00. There is some fiddlyness to the last step. Often it will require a few more hits of play, always stopping again at the interrupt handler spot before it finally resets with the lockup bit.
If I hit the red stop button, and then right click on the application in the debug window and say "relaunch", this entire cycle starts all over.
There is little remarkable about my circuit. I copied the reset circuit from the TWR-K20D72M board, a 10k pullup with a switch to pull reset to gnd and a 0.1uF cap in parallel with the switch. I am using a 16MHz crystal. I screwed up and ran it into the 32KHz osc pins, so I cut the traces and ran 2 short airwires to the correct pins. I've scoped the clock and it looks really good. I don't have the 1meg resistor in parallel with the cap though.
Anyway, I'm all out of ideas on how to track this down. Any help would be greatly appreciated.