I have an odd problem! I have migrated a project from K22 to K24 on custom hardware. For some reason the K24 has a hard fault for no apparent reason sometimes during startup (C startup and initialisation before main is called). Sometimes it makes it past this and breaks at the start of main. If I run the code from there it may or may not run continuously, or it will have the same hard fault. If it does make it to main, then I single step through all off my initialisation code then let it run continuously in the main loop it will not trap!
This has me buggered! I thought clock setup but after a reset it is back to default settings. It is not due to my code I don't think as it traps during the C init sometimes. Before my code is called and with default clock setup.
I did notice during debugging that sometimes the clock setup registers are not written to correctly and when read back for clock rate determination they give the wrong values! But again, this is only after it has made it past startup code!
The trap it has is UNDEFINSTR. This occurs intermittently say 60% of the time. But the code path followed during startup is identical each time!
Any ideas appreciated...