System Reset

Showing results for 
Search instead for 
Did you mean: 

System Reset

NXP Employee
NXP Employee
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?

LPC1226 part.


Writing the update items in assembly.
Labels (1)
0 Kudos
1 Reply

NXP Employee
NXP Employee
Content originally posted in LPCWare by Daniel Widyanto on Tue Dec 18 23:59:00 MST 2012

Wait until the memory access is done.
#define SCB_AIRCR_VECTKEY_Pos              16
#define SCB_AIRCR_VECTKEY_Msk              (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)

void NVIC_SystemReset(void)
  __asm volatile ("dsb"); //__DSB();                           /* Ensure all outstanding memory accesses included
                                                                  buffered write are completed before reset */             
  SCB->AIRCR  = ((0x5FA << SCB_AIRCR_VECTKEY_Pos)      |
  __asm volatile ("dsb"); //__DSB();                           /* Ensure completion of memory access */             
  while(1);                                                    /* wait until reset */
0 Kudos