KL15 Watchdog not working

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

KL15 Watchdog not working

跳至解决方案
1,721 次查看
xaviermao
Contributor II

Dear Freescale Community,

I am currently developing on KL15 microcontroller, Bareboard without PE. As required, I would like to enable watchdog timer for security reasons. Right now I am running a small testing program with watchdog timer enabled at the starting of the main and do not feed anything to it. I expect that the program resets itself frequently. However, the program runs per normal. It looks like the watchdog is never enabled. I am attaching my code for reference. Hope I can get some help in clearing my doubts.

Thank you.

void __init_hardware()

{

  SCB_VTOR = (uint32_t)__vector_table; /* Set the interrupt vector table position */

  // Disable the Watchdog because it may reset the core before entering main().

  SIM_COPC = KINETIS_WDOG_DISABLED_CTRL;

}

void WDG_Enable()

{

  SIM_COPC = (0x08 & 0x0F); // Enable the clock and the timeout count

}

void SysInit()

{  /* Enable the COM Port UART with minimal settings */

  UART0Init(9600);

  UART0HWFCPinInit();

  UART1Init(9600);

  UART1HWFCPinInit();

  /* Initialize the WatchDog */

  WDG_Enable();

  COMSendString("\r\nWDG Enabled");

}

void EnvInit()

{

  /* Create the tasks here */

  CreateComTasks((configMAX_PRIORITIES-2)); // Create the COM task

  CreateModemTask((configMAX_PRIORITIES-2)); // Create the Modem Task

  CreateUpdateTask((configMAX_PRIORITIES-1)); // Firmware Update task with the default source as COM port

  /* Create the Semaphores related with UART1 and UART0 */

  CreateUART1Sem();

  CreateUART0Sem();

}

int main()

{

  /* Initialize the peripherals and GPIO in here */

  SysInit();

  /* Initialize the environment */

  EnvInit();

  vTaskStartScheduler();

  return 0;

}

标签 (1)
标记 (1)
1 解答
1,278 次查看
mjbcswitzerland
Specialist V

Hi

The SIM_COPC register can only be written once after a reset. This means that, since you are immediately disabling it, you can not enable it again later.

Regards

Mark

在原帖中查看解决方案

6 回复数
1,279 次查看
mjbcswitzerland
Specialist V

Hi

The SIM_COPC register can only be written once after a reset. This means that, since you are immediately disabling it, you can not enable it again later.

Regards

Mark

1,278 次查看
xaviermao
Contributor II

Hi Mark,

To my understanding, watchdog time should be able to be enabled in run time.

Regarding

This means that, since you are immediately disabling it, you can not enable it again later.

Can you provide some reference for the above information? I cannot find it stated anywhere.

Thank you.

0 项奖励
回复
1,278 次查看
mjbcswitzerland
Specialist V

Xavier

First line in the KL15P80M48SF0RM.pdf User's Manual describing the register:

COP.PNG.png

Regards

Mark

1,278 次查看
xaviermao
Contributor II

Hi Mark,

You are right, I miss understood the statement. I thought it can be written multiple times, but immediately after a reset. Previously I tested without disabling watchdog timer in my program but it was not working. It turned out that SIM_COPC was assigned to 0x00 in the device bootloader. As a result, it was always disabled no matter what I do in my program.

Thank you so much for pointing out it !

Best regards,

Xavier

1,278 次查看
perlam_i_au
Senior Contributor I

You mention that you expect continuously reset from your target device with this small test code but I am not sure about how you want to make this happen, I really would like to check your project if you want to share it.


Have a nice day,
Perla Moncada

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
1,278 次查看
xaviermao
Contributor II

Hi Moncada,

Thank you for your reply. I have updated the code in my previous question statement for your reference.

Basically, the project runs with FreeRTOS. inside the main(), after certain initialization including enable watchdog timer, it starts the task scheduler. The watchdog timer is enabled inside SysInit() as showing and a debug message is printed after that. The watchdog timer is never fed again after this initialization. If the watchdog timer timeout, I expect a reset of the system and hence repeating of the debug message. But the system runs as normal. The debugging message is not repeated.

Thank you! Hope to hear from you soon.

0 项奖励
回复