AnsweredAssumed Answered

Reset_Handler when unlocking Watchdog at SystemInit()

Question asked by Tharon Hall on Jan 28, 2015
Latest reply on Feb 23, 2015 by Matt Lang

I have configured my Processor Expert so I can target the 64-pin K22F device on the FRDM-K22F board, or the 100-pin "MK22FN512VLL12" MCU on our target board. I can talk to our board from KDS using Multi-Link just fine, but things fail immediately on startup.

 

The code attempts to unlock the watchdog at startup, but then immediately jumps to the Reset_Handler. This code presumably worked when executed on the FRDM-K22F board.

 

Here is the code, which was generated by PE:

 

/* ----------------------------------------------------------------------------

   -- SystemInit()

   ---------------------------------------------------------------------------- */

 

void SystemInit (void) {

#if ((__FPU_PRESENT == 1) && (__FPU_USED == 1))

  SCB->CPACR |= ((3UL << 10*2) | (3UL << 11*2));    /* set CP10, CP11 Full Access */

#endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */

 

#if (DISABLE_WDOG)

  /* WDOG->UNLOCK: WDOGUNLOCK=0xC520 */

  WDOG->UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520); /* Key 1 */ <--- HERE IS WHAT EXECUTES AND EXECUTION GOES TO THE RESET HANDLER

  /* WDOG->UNLOCK: WDOGUNLOCK=0xD928 */

  WDOG->UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xD928); /* Key 2 */

  /* WDOG->STCTRLH: ?=0,DISTESTWDOG=0,BYTESEL=0,TESTSEL=0,TESTWDOG=0,?=0,?=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=1,WINEN=0,IRQRSTEN=0,CLKSRC=1,WDOGEN=0 */

  WDOG->STCTRLH = WDOG_STCTRLH_BYTESEL(0x00) |

                 WDOG_STCTRLH_WAITEN_MASK |

                 WDOG_STCTRLH_STOPEN_MASK |

                 WDOG_STCTRLH_ALLOWUPDATE_MASK |

                 WDOG_STCTRLH_CLKSRC_MASK |

                 0x0100U;

#endif /* (DISABLE_WDOG) */

 

Any thoughts on even where to start looking? Is it possible there is a bug in the PE code???

Outcomes