AnsweredAssumed Answered

Waking up issues with watchdog timer and wake-up timer

Question asked by Kamran Farhangi on Nov 24, 2018
Latest reply on Nov 27, 2018 by Kamran Farhangi

Hi all,

I am using an LPC 824, and I'm trying to wake it up 250 ms after going to DeepSleep (or Power-Down mode). I tried using the Wake-up timer and the watchdog timer to wake it up, but for some reason it does not work.


This is the init part of the code for using the WDT:

//Setting watchdog timer up

/* Freq = 0.6Mhz, divided by 64. WDT_OSC should be 9.375khz */
Chip_Clock_SetWDTOSC(WDTLFO_OSC_0_60, 64);

/* Enable the power to the WDT */

/* Initialize WWDT (also enables WWDT clock) */


and this is the interrupt handler:

void WDT_IRQHandler(void)
   uint32_t wdtStatus = Chip_WWDT_GetStatus(LPC_WWDT);

   if (wdtStatus & WWDT_WDMOD_WDTOF) {
      //printf("Inside watchdog timer handler\n");
      /* A watchdog feed didn't occur prior to window timeout */
      Chip_WWDT_UnsetOption(LPC_WWDT, WWDT_WDMOD_WDEN); /* Stop WDT */
      Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDTOF);


and this is the main code putting the MCU in DeepSleep mode:

if(goToSleep) { 
   #define WAKE_UP_EVERY_MS 250

   /* The WDT divides the input frequency into it by 4 */
   uint32_t wdtFreq = Chip_Clock_GetWDTOSCRate() / 4;
   Chip_WWDT_SetTimeOut(LPC_WWDT, wdtFreq * WAKE_UP_EVERY_MS / 1000);
   /* Clear watchdog warning and timeout interrupts */
   /* Clear and enable watchdog interrupt */

   /* Start watchdog */

   //LPC is now in DeepSleep state

   timems += WAKE_UP_EVERY_MS;



When I uncomment the printf, and don't put the MCU in sleep, I can see that the interrupt is called as it should. But for some reason it is either does not interrupt or does not wake the MCU up while it is in sleep mode.


I also tried using wake-up timer and the result was exactly the same. Works good then MCU is awake, but does not work in sleep mode!


Thank you in advance for your help.