<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis Microcontrollers中的主题 Re: Watchdog timer for KL26</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Watchdog-timer-for-KL26/m-p/434809#M25282</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mridul Pandey:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The watchdog or COP (Computer Operating Properly) in KL26 is very simple and not hard to configure. You only need to configure the &lt;STRONG&gt;SIM_COPC&lt;/STRONG&gt; register according to &lt;STRONG&gt;Table 3-23&lt;/STRONG&gt; &lt;STRONG&gt;COP configuration options&lt;/STRONG&gt; in the KL26 Reference Manual:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;IMG alt="pastedImage_0.png" src="https://community.nxp.com/t5/image/serverpage/image-id/52877i153A92B71EF158D3/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_0.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the example code below for FRDM-KL26 the COP is configured for a 1 second timeout. If you compile with the macro RESET_WDOG = 0 the blue LED will toggle each second because the MCU is resetting. Otherwise if you compile with RESET_WDOG = 1, the counter is refreshed in the while loop and the MCU does not reset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;:smileyalert: Make sure that the SIM_COPC is not written in the startup code of the project. Typically the watchdog is disabled at startup and this register can only be written once after reset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14395077637665014 jive_text_macro" data-renderedposition="543.36669921875_8_1050_592" jivemacro_uid="_14395077637665014" modifiedtitle="true"&gt;&lt;P&gt;#include "MKL26Z4.h"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define RESET_WDOG&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int counter = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize blue LED */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enable clock gate for PORTD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTD_PCR5 = PORT_PCR_MUX(1);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // PTD5 as GPIO&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOD_PDDR |= (1 &amp;lt;&amp;lt; 5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // PTD5 as output&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOD_PDOR &amp;amp;= !(1 &amp;lt;&amp;lt; 5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Output 0 [Blue LED off]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (counter = 0; counter &amp;lt;= 50000; counter++){}&amp;nbsp;&amp;nbsp;&amp;nbsp; // Delay&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOD_PDOR |= (1 &amp;lt;&amp;lt; 5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Output 1 [Blue LED on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Configure watchdog (COP) */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_COPC = 0xC; // COPT = 11&amp;nbsp;&amp;nbsp;&amp;nbsp; [Timeout after 2^10 LPO cycles] OR [Timeout after 2^18 bus clock cycles]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // COPCLKS = 0&amp;nbsp;&amp;nbsp;&amp;nbsp; [LPO (1kHz) clock selected]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // COPW = 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Normal mode]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Timeout = (1/LPO clock) x 2^10 = (1/1 kHz) x 2^18 = 1 s&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;#if RESET_WDOG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (counter = 0; counter &amp;lt;= 50000; counter++){}&amp;nbsp;&amp;nbsp;&amp;nbsp; // Delay&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SRVCOP = 0x55;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SRVCOP = 0xAA;&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The COP is also supported by the KSDK platform library, which you can download from the platform page: &lt;A href="http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KINETIS-SDK&amp;amp;tid=redKINETIS_SDK" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank" title="http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KINETIS-SDK&amp;amp;tid=redKINETIS_SDK"&gt;Software Development Kit for Kinetis MCUs|Freescale&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once installed you can find an example for COP in the next installation path:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C:\Freescale\KSDK_1.2.0\examples\frdmkl26z\driver_examples\cop&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards!,&lt;BR /&gt;Jorge Gonzalez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 13:20:48 GMT</pubDate>
    <dc:creator>Jorge_Gonzalez</dc:creator>
    <dc:date>2020-11-02T13:20:48Z</dc:date>
    <item>
      <title>Watchdog timer for KL26</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Watchdog-timer-for-KL26/m-p/434808#M25281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was trying to find something in the documents provided by freescale and also sample BSP provided by freescale. I wanted to use watchdog timer for my project. Can someone please help me with a sample code of watchdog timer initialisation, setting the timer and using it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please post me some example to learn watchdog functioning on freedom kl26 board.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2015 14:08:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Watchdog-timer-for-KL26/m-p/434808#M25281</guid>
      <dc:creator>mridulpandey</dc:creator>
      <dc:date>2015-08-12T14:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Watchdog timer for KL26</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Watchdog-timer-for-KL26/m-p/434809#M25282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mridul Pandey:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The watchdog or COP (Computer Operating Properly) in KL26 is very simple and not hard to configure. You only need to configure the &lt;STRONG&gt;SIM_COPC&lt;/STRONG&gt; register according to &lt;STRONG&gt;Table 3-23&lt;/STRONG&gt; &lt;STRONG&gt;COP configuration options&lt;/STRONG&gt; in the KL26 Reference Manual:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;IMG alt="pastedImage_0.png" src="https://community.nxp.com/t5/image/serverpage/image-id/52877i153A92B71EF158D3/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_0.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the example code below for FRDM-KL26 the COP is configured for a 1 second timeout. If you compile with the macro RESET_WDOG = 0 the blue LED will toggle each second because the MCU is resetting. Otherwise if you compile with RESET_WDOG = 1, the counter is refreshed in the while loop and the MCU does not reset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;:smileyalert: Make sure that the SIM_COPC is not written in the startup code of the project. Typically the watchdog is disabled at startup and this register can only be written once after reset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14395077637665014 jive_text_macro" data-renderedposition="543.36669921875_8_1050_592" jivemacro_uid="_14395077637665014" modifiedtitle="true"&gt;&lt;P&gt;#include "MKL26Z4.h"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define RESET_WDOG&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int counter = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize blue LED */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTD_MASK;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enable clock gate for PORTD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORTD_PCR5 = PORT_PCR_MUX(1);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // PTD5 as GPIO&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOD_PDDR |= (1 &amp;lt;&amp;lt; 5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // PTD5 as output&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOD_PDOR &amp;amp;= !(1 &amp;lt;&amp;lt; 5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Output 0 [Blue LED off]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (counter = 0; counter &amp;lt;= 50000; counter++){}&amp;nbsp;&amp;nbsp;&amp;nbsp; // Delay&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GPIOD_PDOR |= (1 &amp;lt;&amp;lt; 5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Output 1 [Blue LED on&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Configure watchdog (COP) */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_COPC = 0xC; // COPT = 11&amp;nbsp;&amp;nbsp;&amp;nbsp; [Timeout after 2^10 LPO cycles] OR [Timeout after 2^18 bus clock cycles]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // COPCLKS = 0&amp;nbsp;&amp;nbsp;&amp;nbsp; [LPO (1kHz) clock selected]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // COPW = 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Normal mode]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Timeout = (1/LPO clock) x 2^10 = (1/1 kHz) x 2^18 = 1 s&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;#if RESET_WDOG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (counter = 0; counter &amp;lt;= 50000; counter++){}&amp;nbsp;&amp;nbsp;&amp;nbsp; // Delay&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SRVCOP = 0x55;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIM_SRVCOP = 0xAA;&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The COP is also supported by the KSDK platform library, which you can download from the platform page: &lt;A href="http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KINETIS-SDK&amp;amp;tid=redKINETIS_SDK" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank" title="http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KINETIS-SDK&amp;amp;tid=redKINETIS_SDK"&gt;Software Development Kit for Kinetis MCUs|Freescale&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once installed you can find an example for COP in the next installation path:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C:\Freescale\KSDK_1.2.0\examples\frdmkl26z\driver_examples\cop&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards!,&lt;BR /&gt;Jorge Gonzalez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:20:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Watchdog-timer-for-KL26/m-p/434809#M25282</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2020-11-02T13:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Watchdog timer for KL26</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Watchdog-timer-for-KL26/m-p/434810#M25283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jorge,&lt;/P&gt;&lt;P&gt;It was a great help. I Tried it and it worked fine. :smileyhappy:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 12:13:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Watchdog-timer-for-KL26/m-p/434810#M25283</guid>
      <dc:creator>mridulpandey</dc:creator>
      <dc:date>2015-08-19T12:13:09Z</dc:date>
    </item>
  </channel>
</rss>

