LPC845 - disable Watchdog before application jumps to bootloader

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

LPC845 - disable Watchdog before application jumps to bootloader

2,618 Views
jtro
Contributor III

I'm successfully jump from bootloader to application and application to bootloader.

Please note I'm not using watchdog in my bootloader.

When I'm enable watchdog in application it successfully jumps to bootloader but it reset after watchdog timeout. when I'm disable (not initialize) watchdog then it works.

Application to bootloader jump Code:

WWDT_Deinit(WWDT);
POWER_DisablePD(kPDRUNCFG_PD_WDT_OSC);
NVIC_DisableIRQ(WDT_IRQn);
while(xUART[0].u1TxOnGoing); // wait till UART send all bytes
FirmwareUtility_Boot(0x3000);

 

void FirmwareUtility_Boot(U32 u32Address)
{
/* Ref: https://community.nxp.com/thread/494497 */
typedef void (*APPLICATION)(void);

APPLICATION xEntryPoint;

// Clear all interrupts and disable before vector reallocate
_ClearDisableAllIRQ();

/* Disable SysTick timer */
SysTick->CTRL &= ~(SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk);

// Vector reallocate
__DSB();
__ISB();
__set_MSP(*((U32 *)u32Address));
SCB->VTOR = (u32Address & SCB_VTOR_TBLOFF_Msk);
__DSB();
__ISB();

xEntryPoint = (APPLICATION) *((U32 *)(u32Address + 4));

_DisablePLL();
xEntryPoint();
}

 

Labels (1)
0 Kudos
Reply
5 Replies

2,438 Views
frank_m
Senior Contributor III

I would need to read the manual for the LPC845, but for almost all other MCUs I came across, a watchdog cannot be disabled once it is enabled. This is by design.

> I'm successfully jump from bootloader to application and application to bootloader.

We use bootloaders for all our devices, on several architectures.

However, we do never "jump" from application to bootloader, but set a specific "stay in BL flag", and reset the device to get back into the BL. Often simply by a busy loop to run into the watchdog-reset.

The BL only executes the application if it is correct (checksum), and the "stay in BL" flag is not set.

0 Kudos
Reply

2,606 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi jtro 

You may set flag in your boot code to monitor where your code invoke watchdog.

But I suggest you disable watchdog before entering main code. some system initialization code. Normally we won't see any problem in a new created project.

But for example If the code includes  large global array, RAM initialization in startup code takes time. If the program has many global variables to be initialized, technically it's hard to feed dog during the initialization process. 

So it's right to watchdog before enter your application. enable it after the code gets into application. 

Have a nice day,

Jun Zhang

0 Kudos
Reply

2,579 Views
jtro
Contributor III

That's what I have asked in my first post I'm disabling watchdog before jump but not able to disable it.

In user manual (Rev. 1.6 — 8 December 2017) page 416 I found it is written that "“Safe” watchdog operation. Once enabled, requires a hardware reset or a Watchdog reset to be disabled." check attached image.

Is it that once I enable watchdog then I can't disable it in same application without reset?

0 Kudos
Reply

2,444 Views
andarm
Contributor II

I seems got the same issue with LPC1830. 

Once I open WWDG, I found it can not disable. 

I found  the register value is  "LPC_WWDT->MOD = 3".  But register is out of control. Even if I has disable wwdt interupt trigger. 

 NVIC_DisableIRQ(WWDT_IRQn);  But still not working. 

0 Kudos
Reply

2,571 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

try to set watchdog WINDOW register as 0xFF FFFF in the beginning of your startup code. see if this can resolve the issue.

0 Kudos
Reply