LPC55S69 - Forcing system reset in software

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC55S69 - Forcing system reset in software

1,514 Views
scottm
Senior Contributor II

What's the accepted way to force a system reset in software for the LPC55S69? The manual says setting SYSCON->SWR_RESET to 0x5a00_0001 will do it, but I can't get it to do anything - my code does it in a perpetual loop, in fact, and the system never resets.

Also, is there a way to do it from the MCUX SDK? The "Reset Driver" documentation says it handles both peripheral resets and system resets but there's no other mention of a system reset.

Scott

0 Kudos
6 Replies

1,342 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

As the following Figure, Pls set the SWRRESETENABLE bit in RESETCTRL register and have a try.

When you set the SWRRESETENABLE bit in RESETCTRL register to enable the software control, then write SYSCON->SWR_RESET to 0x5a00_0001, the software reset will be enabled.

 

xiangjun_rong_0-1688958755383.png

BR

XiangJun Rong

0 Kudos

1,317 Views
scottm
Senior Contributor II
 

scottm_1-1689016111523.png

Maybe you can help me understand what's going on here. I've set the SWRRESETENABLE bit and it executes the write to SWR_RESET. I've confirmed that r2 does hold the correct value of 0x5a000001. It doesn't reset, though, and continues to the next instruction - which for some reason is an infinite loop. I can't see why it would compile that way.

Edit: It looks like my immediate problem is actually on the P&E side. I've been generating an image of the bootloader for the Cyclone to load standalone, and then the debugger is set to preserve the bootloader range. Only the standalone programming algorithm is broken and isn't actually programming the bootloader area, and doesn't throw a verification error, so I've been repeatedly testing against an old version of the bootloader that was still in memory, probably loaded by an LPC-Link2 days ago.

Now the P&E burner crashes if I try to load multiple object files and the interactive programmer won't work, so I guess I'm back to the LPC-Link2 until P&E comes up with a fix. I'll try Erich's suggestion of using the gdb load command.

0 Kudos

1,336 Views
scottm
Senior Contributor II

Thanks, I'll give that a try in the morning. Does it have any functional difference compared to the SCB AIRCR register? SYSCON is an NXP module, right? And the SCB is an ARM component?

I'd attempted to use both in my bootloader and in both cases the system seemed to be just freezing there. The application code has a shell command that performs a reset using the SCB (carried over from the Kinetis version of the project) and that does seem to function as expected. There may be something else going on.

Is there are software reset provided in the MCUX SDK? The reset driver documentation says it supports system resets but doesn't provide any other documentation.

Scott

0 Kudos

1,287 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I have modified the LED_Blinky project with inserting the software reset code, I suppose that the software reset functions, because the LED dies not toggle after inserting the software reset.

BR
XiangJun Rong

 

int main(void)
{
/* Init output LED GPIO. */
GPIO_PortInit(GPIO, BOARD_LED_PORT);
/* Board pin init */
/* set BOD VBAT level to 1.65V */
POWER_SetBodVbatLevel(kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false);
BOARD_InitBootPins();
SystemCoreClockUpdate();

asm("nop");
asm("nop");
asm("nop");
asm("nop");
PMC->RESETCTRL|=1<<3;
SYSCON->SWR_RESET= 0x5a000001;
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");

/* Set systick reload value to generate 1ms interrupt */
if (SysTick_Config(SystemCoreClock / 1000U))
{
while (1)
{
}
}

while (1)
{
/* Delay 1000 ms */
SysTick_DelayTicks(1000U);
GPIO_PortToggle(GPIO, BOARD_LED_PORT, 1u << BOARD_LED_PIN);
}
}

0 Kudos

1,269 Views
scottm
Senior Contributor II

Thanks for checking. The main problem with my case was that the P&E algorithm was defective and the bootloader wasn't actually getting updated when I recompiled it.

Is there no MCUX SDK system reset function? The docs say there is but it's not documented and I can't find it.

Scott

0 Kudos

1,451 Views
ErichStyger
Senior Contributor V

Hi @scottm ,

I'm using the SCB register for the LPC55S69 as for all the other ARM Cortex-M cores, see https://mcuoneclipse.com/2015/07/01/how-to-reset-an-arm-cortex-m-with-software/

You can find the SoftwareReset function here too:

https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/src/McuArmTools.c

Alternatively, you can use the CMSIS function (pasted below):

/**
  \brief   System Reset
  \details Initiates a system reset request to reset the MCU.
 */
__STATIC_INLINE void __NVIC_SystemReset(void)
{
  __DSB();                                                          /* Ensure all outstanding memory accesses included
                                                                       buffered write are completed before reset */
  SCB->AIRCR  = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos)    |
                           (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
                            SCB_AIRCR_SYSRESETREQ_Msk    );         /* Keep priority group unchanged */
  __DSB();                                                          /* Ensure completion of memory access */

  for(;;)                                                           /* wait until reset */
  {
    __NOP();
  }
}

Erich