Watchdog initialization problem

froeber

Well-known member
Hi all, I've been trying to get the Teensy3.0 watchdog timer to work with the low power oscillator (LPO) clock source. I was having no luck until I got hooked up to a Freescale support engineer who gave me some simple example code he said "worked for him". Well even that simple code didn't work for me. So I figured it must be a BSP setup difference between the Freescale "bare metal" environment he was using and the Teensy3 BSP.

I went through a bunch of code before coming to a key difference in the very first few lines of startup code. I found the Teensy3 code in the ResetHandler function in mk20dx128.c did:
WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;
WDOG_UNLOCK = WDOG_UNLOCK_SEQ2;
WDOG_STCTRLH = WDOG_STCTRLH_ALLOWUPDATE;

Whereas the Freescale startup code did:

WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;
WDOG_UNLOCK = WDOG_UNLOCK_SEQ2;
WDOG_STCTRLH &= ~WDOG_STCTRLH_WDOGEN;

I changed the Teensy code to match the Freescale code and then the Watchdog worked with the LPO option. I think the issue is that the original Teensy code changed the watchdog to use the LPO option right away and that somehow caused problems. Anyways, it clearly would make more sense to use the Freescale code.

I'm still using release 1.16 of TeensyDuino but I figure this hasn't been changed in the newer releases. So I'm hoping Paul can fix it at some point.
Fred
 
Back
Top