Content originally posted in LPCWare by jdurand on Thu Nov 15 11:13:20 MST 2012 Now that I have my code working and a preliminary version shipped, I have one thing pending that I have to investigate more.
At the end of my firmware update I need to reboot the system. Looking at the CMSIS system reset function it seemed all I had to do was write a magic number to the AIRCR register and all would be well.
Except, that's getting me a hard fault. I double checked what I'm writing and it SEEMED ok, but since I had to get this out I changed the code to load SP from memory address 0x00000000 and then jump to the address pointed to in memory address 0x00000004. This seems to restart everything fine but of course it didn't do a RESET on the GPIO and other registers. For now, this is a shippable option.
As a quick test, I also enabled the WDT in my code with a long timeout (more than plenty to update the firmware since I do a block copy from external memory). This reset right on schedule but it also went to hard fault instead of actually restarting the code.
So, is there anything magic about resetting the system that I missed?