I'm working on a BLDC motor project and am trying to test some algorithms on a FRDM-KV11 board with KDS. I'm stuck right now because I'm getting a hard fault in the PEX_RTOS_INIT function called from PE_low_level_init(). The hard fault occurs on a push instruction that's putting r4-r7 plus the link register. That instruction is the first one of a compiler support function labeled "_udivdi3" (address 0xa48) and the the previously executed instruction is a bl to this function at address 0x668. The MSP is the only stack pointer being used and it's pointing to RAM at an address (0x20002fa0) that's long word aligned (lower 2 bits = 0). RAM exists at that address as evidenced by being able to display it's contents in a Memory Monitor window.
The hard fault results in the transfer of execution to the default interrupt handler with the xPSR = 0x41000003 (the '03' in the lower bits indicates a hard fault occurred).
I can see no reason for this hard fault to occur but it consistently does happen except that one time after disconnecting everything and restarting KDS. After that the entire PE_low_level_init function executed normally several times (along with the rest of the program) but when I made a small change to my code (added two lines in the FTM1 IRQ handler) it went back to generating the hard fault on the same instruction as before. Subsequent attempts to get it working again by disconnecting everything and restarting KDS has had no effect.
I'm using a J-Link SWD adapter for debugging and powering the board via the micro USB connection to the board. I've also tried powering the board VIA a FRDM_MC_BLDC shield and get the same result.
The attached zipfile should contain everything needed to recreate the project in KDS. NXP.zip contains some motor control library files which are referenced by the project but are not actually used (yet).