Daniel Truong

booting from ROM (FTFA_FOPT[7:6]=11) disables watchdog

Discussion created by Daniel Truong on Aug 11, 2017
Latest reply on Sep 22, 2017 by Robert Poor

I have the following puzzling issue and wonder if somebody had similar experiences and willing to share your thoughts:


I implemented a watchdog timer in my program to reset the processor if it ever went astray. One condition for the watchdog to work is you have to manually set the directive DISABLE_WDOG to 0 (i.e. enable the watchdog) in file "system_MKL27Z4.h", otherwise the following piece of code in file "system_MKL27Z4.c" will get executed at start up:




  SIM->COPC = (uint32_t)0x00u;

#endif /* (DISABLE_WDOG) */


As a result, the watchdog is disabled by default.

Since register SIM->COPC  can only be written once, it can't be rewritten by user to enable the feature.


Everything was working fine until I decided to make a change to "boot from ROM" in order to enable the firmware upgrade feature from external host. Then the watchdog feature stops working, i.e. SIM->COP register can't be written in my application (it remains as 0 as if it was written by 0 somewhere in the startup program).

The change I made was to modify the Flash Configuration Area in the file “startup_MKL27Z4.S” as follows:


/* Flash Configuration */
.section .FlashConfig, "a"
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFE                //was 0xFFFF3DFE


This means that contents of reg FTFA_FOPT was altered to force the processor to boot from ROM, where codes from ROM will conduct a dialog with the host (via USB in my case) to facilitate any firmware upgrade on the field.


If I changed back to original form (FF to 3D) then the watchdog feature came back and the program was running fine.

My platform is:

Processor MKL27Z256xxx


KDS v3.2.0


If anybody knows what I'm talking about or had prior experience about this issue, please share your thought. Your help would be greatly appreciated.