LPC845: resetting M0+ Core and Peripherals

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

LPC845: resetting M0+ Core and Peripherals

1,428 Views
rene_kniest
Contributor I

MicroController: LPC845

Subject: Resetting peripherals and Core to jump from BootLoader to Application

When jumping from BootLoader to Application I'd like to get rid of all history

(e.g. clock settings, inits of peripherals, pending interrupts) by

1. setting VTOR to 0x2000, as follows:

    *((volatile uint32_t*) 0xE000ED08) = 0x00002000;

2. resetting all peripherals and the Cortex-M0+ Core

With the sequence 

*((volatile uint32_t*) 0xE000ED08) = 0x00002000;

NVIC_SystemReset();

in combination with calling function SYS_ResetAllPeripherals (see below),

immediately after reset, this goal is not achieved

(and it's hard to debug this low level stuff, going through reset).

I would appreciate any advise on this matter.

// -----------------------------------------------------------------------------
// Function : SYS_ResetAllPeripherals()
// Comment  : Reset all peripherals (which can be reset by
//                     means of PRESETCTRL0 and PRESETCTRL1)
//                     except the Flash Controller
// Params   :
//   Input  : -
//   Output : -
// Return   : -
// -----------------------------------------------------------------------------
void SYS_ResetAllPeripherals(void)
{
 // Activate reset of all peripherals
    LPC_SYSCON->PRESETCTRL0 = 0x0402001F;
    LPC_SYSCON->PRESETCTRL1 = 0xFFFFFFE4;
    // Deactivate peripheral reset
    LPC_SYSCON->PRESETCTRL0 = 0xFFFFFFFF;
    LPC_SYSCON->PRESETCTRL1 = 0xFFFFFFFF;
}
Labels (1)
0 Kudos
4 Replies

1,015 Views
starblue
Contributor III

VTOR is set to 0 on reset (see ARM document DUI0662 page 2-18), so this approach won't work .

Instead you can simulate the reset behavior, at a minimum by using your vector table to load the stack pointer and jump to the reset vector.

0 Kudos

1,015 Views
rene_kniest
Contributor I
Hi Jürgen,

The approach I sketched on August 3 is working fine.
Thanks again for your reply of August 2.

Regards, René
0 Kudos

1,015 Views
rene_kniest
Contributor I
Hi Jürgen,

I appreciate your reply, that surely helps.
What I'd like to achieve is to get rid of all history when switching from BootLoader to Application.
(e.g. clock settings, inits of peripherals, pending interrupts).
[that means not only resetting the M0+ Core, but reset the peripherals too]
The sketch of how to achieve this is added below.
I'll test it one of the coming days.

Regards, René


Switch from BootLoader to Application:
  • store in Flash: modeOfOperation = Application
  • enable the WatchDog, enable a WatchDog reset, with a short timeout (WatchDog Timer Constant register)
  • do not feed the WatchDog [a while(1); is fine]
    according to 22.6.1 in UM11029.pdf (LPC84x User Manual)
    this results in a chip reset (so it seems that peripherals are also reset)

At startup:
if (modeOfOperation == Application)
{
    JumpToUserApplication(); // Does not return
}
// BootLoader functionality here

void JumpToUserApplication(void)
{
    pFunction appEntry;
    uint32_t appStack;

    /* Get the application stack pointer (First entry in the application vector table) */
    appStack = (uint32_t) *((volatile uint32_t*) USER_APP_ADDRESS);

    /* Get the application entry point (Second entry in the application vector table) */
    appEntry = (pFunction) *(volatile uint32_t*) (USER_APP_ADDRESS + 4);

    /* Reconfigure vector table offset register to match the application location */
    //SCB->VTOR = USER_APP_ADDRESS;
    *((volatile uint32_t*) 0xE000ED08) = USER_APP_ADDRESS;

    /* Set the application stack pointer */
    __set_MSP(appStack);

    /* Start the application */
    appEntry();  // Does not return
}
0 Kudos

1,015 Views
jeremyzhou
NXP Employee
NXP Employee

Hi René Kniest,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
I haven't found you to execute jumping to the application after configuring VTOR register.
To provide the fastest possible support, I'd highly recommend you to refer to some bootloader application notes for details.
You can download these bootloader applications notes via the following link.
https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/lpc-corte...


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos