lpcware

Watchdog on the LPC4088

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by jdowd on Wed Jun 25 13:55:01 MST 2014
I'm having trouble making the watchdog fire on this processor. The example code I've found is for the LPC11XX family.

I have programmed for a minimal watchdog with no Warn or Protect enabled. Just a straight count down from the default value of 0xff.
This means that I have a 0x03 in the Mode register (enable and Reset). I leave the TC register alone since it's reset value is 0xff. I then "feed" the watchdog once and only once. I then turn on the WDT_IRQn vector and enter a loop.

I have a console programmed up and in it I can look at the TV register value. It is only ever 0xff. No decrement ever happens and the watchdog never goes off.

I have looked at the User Manual and there is a dedicated oscillator to drive the watchdog functionality and it does not appear to have to be "selected" or enabled. There is mention of a PCLK but amount of searching shows a bit in anything that will enable the watchdog.

This is different than the LPC1768 in which the clock has to be selected for the watchdog. So, any demo code I find is only able to be compiled if I use a 1768 and not a 4088.

Here is my starting code snippet....

  NVIC_DisableIRQ(WDT_IRQn);

  /* Setup the Watchdog timer operating mode in WDMOD register */
  theValue = *(uint32_t*)(this->theBaseRegister + Watchdog::WDT_Register_MOD);
  theValue = (theValue & ~(theModeBM)) | theModeBM;
  *(uint32_t*)(this->theBaseRegister + Watchdog::WDT_Register_MOD) = theValue;

  /* Set a value for the Watchdog window time in WDWINDOW if windowed operation required */

  /* Set a value for the Watchdog warning interrupt in the WDWARNINT register if a warning interrupt is required */

  theValue = *(uint32_t*)(this->theBaseRegister + WDT_Register_MOD);
  theValue |= WDT_Mode_Running;
  *(uint32_t*)(this->theBaseRegister + WDT_Register_MOD) = theValue;

  /* Enable the Watchdog by writing 0xAA followed by 0x55 to the WDFEED register */
  __disable_irq();
  *(uint32_t*)(this->theBaseRegister + WDT_Register_FEED) = 0xaa;
  *(uint32_t*)(this->theBaseRegister + WDT_Register_FEED) = 0x55;
  __enable_irq();

  /* The Watchdog must be fed again before the Watchdog counter reaches zero in order
   * to prevent a Watchdog event. If a window value is programmed, the feed must also
   * occur after the Watchdog counter passes that value.
   */

  NVIC_EnableIRQ(WDT_IRQn);


Cheers!!

Outcomes