The watchdog register COP is a Write-Once register.
Check in the early startup files to see if it is being disabled there.
Sadly almost all startup's I've looked at do this. :-(
See how I handle this in my vectors.c below.
Until watchdog_init() is defined in some other file the watchdog will be disabled.
When I'm ready to turn the watchdog on I add a watchdog.c/.h that does The Right Stuff in watchdog_init().
In vectors.c (the first file run, gcc compiler):
void watchdog_init( void ) __attribute__ ((weak, alias("watchdog_turn_off")));
static void watchdog_turn_off( void ); /* The watchdog register may only be written to a single time after reset. Default to turning it off */
static void watchdog_turn_off( void ) /* Make sure to override this in a real shipping product. Also account for Bootloader, in MKL43/MKL27 etc, turned it off so need to from Flash */
{
SIM_COPC = 0U; /* Disable the watchdog timer */
}
void _reset_init(void)
{
irq_disable(); /* Did bootloader leave IRQs on perhaps? */
SCB_VTOR = (uint32_t) interrupt_vector_table;
sync_barrier_data();
/*
* The watchdog and power mode registers may only be written to a single time after
* reset. Default to turning it off. Override these function in a
* shipping product if needed:
*/
watchdog_init();
...
}