We're developing a custom bootloader for the k65 using the TWR-K65F180M tower board for development. We're currently trying to get the platform up but are running into an issue where the board randomly hard faults. The following steps are performed:
- Disable watchdogs, MPU, and FPU
- Bring up an initialize clocks based on external 16 MHz clock source. Enter PEE mode.
- Enable Port A for LED control and set pins/directions
- Update VTOR to point to ram vector table (aligned as indicated in the Cortex M-4 manual)
- Enter main
- Enter infinite loop that blinks an LED and counts each loop increment.
What we observe is that the loop runs for a bit, and then randomly we get a hard fault (0x3) and vector off to the handler. The count of the loop counter when we get the fault is always different, but it's always a hard fault, and the PC is always pointing to the instruction which would occur after the infinite loop (it shouldn't ever be reached), and it's misaligned to the next half word boundary. The CFSR register indicates the IACCVIOL fault but we can't seem to track anything down.
We're using the Seger J-Link pro to debug, in the single wire interface mode. We're using SW mode as there was something wrong with the TWR-K65F180M and JTAG mode according to some posts (you had to populate some 0 ohm resistors to get it to work). Could the debugger be causing this?