Author Topic: WDOG operation  (Read 3179 times)

Offline Anton

  • Newbie
  • *
  • Posts: 12
    • View Profile
WDOG operation
« on: April 12, 2019, 10:09:11 AM »
Mark,

I have now more or less a working bootloader + application image running on FRDM-K22F board, where application starts if SW2 is not asserted or application can be started via `go` command after entering bootloader. The thing that bothers me is that if bootloader is entered and then application is executed via `go` command everything works as expected, but if pure reset is performed and application starts directly, then a get a reset every couple of seconds due to wdog (RCM reports 0x20 as the cause of reset). WDOG->STCTRLH register after application boot-up indicates that watchdog is disabled (bit 0 is at logic zero). I've attempted to disable wdog after application start, but that does not seem to help, when jumping directly to applicaton.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: WDOG operation
« Reply #1 on: April 12, 2019, 12:50:30 PM »
Hi

The jump to the application is the same whether GO is executed or it is immediately started. What may be different is that something else was also configured (like ports) when the GO method was used. This is however unlikely to change the application's behavior.

The watchdog is always configured by the boot loader- in your case

#define ACTIVATE_WATCHDOG()    UNLOCK_WDOG(); WDOG_TOVALL = (2000/5); WDOG_TOVALH = 0; WDOG_STCTRLH = (WDOG_STCTRLH_ALLOWUPDATE | WDOG_STCTRLH_STNDBYEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN | WDOG_STCTRLH_WDOGEN); // watchdog enabled to generate reset on 2s timeout (allow updates later if required)

Notice that the watchdog is set to 2s but is not locked, meaning that your application can disable it.

To disable the watchdog in the serial loader you can build it with
#define WATCHDOG_DISABLE()    1

Since I can't explain why the application resetting and also can't disable the watchdog (maybe it is not getting to the watchdog disable?) I would suggest disabling the watchdog in the debugger and setting a break-point in the application initialisation code and subsequently step what is taking place. With the watchdog disabled no WDOG reset should be possible and it may make it easier to detect something.

Good luck

regards

Mark




Offline Anton

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: WDOG operation
« Reply #2 on: April 12, 2019, 05:03:55 PM »
Mark, thanks a lot. #define WATCHDOG_DISABLE()    1 definitely helped.