How do I enable the WatchDog/COP? MKL27Z256

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How do I enable the WatchDog/COP? MKL27Z256

跳至解决方案
1,567 次查看
ericbergstedt
Contributor II

I am using MKL27Z256, 32 pin.

cop_config_t cop_config;

COP_HAL_Init( SIM );
cop_config.copClockSource = kCopLpoClock;
cop_config.copDebugModeEnable = false;
cop_config.copStopModeEnable = false;
cop_config.copTimeout = kCopTimeout_short_2to10_or_long_2to18;
cop_config.copTimeoutMode = kCopShortTimeoutMode;
cop_config.copWindowModeEnable = false;
COP_HAL_SetConfig( SIM, &cop_config );
COP_HAL_Enable();
COP_HAL_Refresh( SIM );

I have this code starting up late after I initialized my entire program. For some reason, I cannot get the COPC register in the SIM module to reflect the changes made above. When I'm in the debug mode and monitoring the SIM module, COPC registers are never changed and stay at 0. I cannot manually change these values within the debugger either, they instantly snap back to zero.

When I'm out of debug mode and lock the main() application, the COP never resets the system.

Is there a special sequence that I must do to modify these values? Any help would be appreciated. I am using KSDK1.3 and using the HAL layer only.

标签 (1)
1 解答
1,125 次查看
ericbergstedt
Contributor II

To enable the watchdog I had to add the follow type define to my Preprocessor Symbols

DISABLE_WDOG=0

Inside of SystemInit() there is a define that will automatically disable the watch dog by default.

Inside of "system_MKL27Z4.h"

There exists this little bit of code

#ifndef DISABLE_WDOG
#define DISABLE_WDOG 1
#endif

Then inside of "startup_MKL27Z4.h"

void SystemInit (void) {

#if (DISABLE_WDOG)
/* SIM->COPC: ?=0,COPCLKSEL=0,COPDBGEN=0,COPSTPEN=0,COPT=0,COPCLKS=0,COPW=0 */
SIM->COPC = (uint32_t)0x00u;
#endif /* (DISABLE_WDOG) */

}

Writing to the Watchdog/COP is a write once register from start up, the above code will take up that one time write far before your application will have a chance to write to it.

This function is called by the Reset_Handler inside of "startup_MKL27Z4.s", which is called before the program even reaches main().

在原帖中查看解决方案

2 回复数
1,126 次查看
ericbergstedt
Contributor II

To enable the watchdog I had to add the follow type define to my Preprocessor Symbols

DISABLE_WDOG=0

Inside of SystemInit() there is a define that will automatically disable the watch dog by default.

Inside of "system_MKL27Z4.h"

There exists this little bit of code

#ifndef DISABLE_WDOG
#define DISABLE_WDOG 1
#endif

Then inside of "startup_MKL27Z4.h"

void SystemInit (void) {

#if (DISABLE_WDOG)
/* SIM->COPC: ?=0,COPCLKSEL=0,COPDBGEN=0,COPSTPEN=0,COPT=0,COPCLKS=0,COPW=0 */
SIM->COPC = (uint32_t)0x00u;
#endif /* (DISABLE_WDOG) */

}

Writing to the Watchdog/COP is a write once register from start up, the above code will take up that one time write far before your application will have a chance to write to it.

This function is called by the Reset_Handler inside of "startup_MKL27Z4.s", which is called before the program even reaches main().

1,125 次查看
albert_zhou
Contributor III

Yes very helpful, The code line DISABLE_WDOG=0 will get warning message. I add a line in the file system_MKL27Z644.H right below #include <stdint>:

#include <stdint.h>


#define DISABLE_WDOG   0  //added  for use watchdog timer

#ifndef DISABLE_WDOG
#define DISABLE_WDOG 1
#endif

0 项奖励
回复