KL15 Watchdog not working

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KL15 Watchdog not working

Jump to solution
1,232 Views
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;

}

Labels (1)
Tags (1)
1 Solution
789 Views
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

View solution in original post

6 Replies
790 Views
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

789 Views
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 Kudos
789 Views
mjbcswitzerland
Specialist V

Xavier

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

COP.PNG.png

Regards

Mark

789 Views
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

789 Views
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 Kudos
789 Views
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 Kudos