<?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中的主题 Enabling Oscillator is causing unhandled interrupt</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528862#M32802</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm trying to port my code from KSDK 1.0.0 to KSDK 1.3.0, using KDS 3.0.0.&amp;nbsp; Device is MK22FN256xxx12.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We need a precise timer in the ms, which means we can't use "OSA_TimeGetMsec()" since it's drifting too much.&amp;nbsp; In KSDK 1.0.0 we manually set the RTC registers and read them.&amp;nbsp; But when I tried to port the code to KSDK 1.3.0, whenever I write 1 to the CR OSCE it will trigger some sort of "&lt;SPAN style="color: #222222; font-family: 'Times New Roman', serif; font-size: 16px;"&gt;WDOG_EWM_IRQHandler()" or &lt;/SPAN&gt;Default ISR.&lt;/P&gt;&lt;P&gt;Seems like I'm missing something here... any help is appreciated... Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the piece of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #909090; font-size: 10pt;"&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; #define BP_RTC_CR_OSCE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (8U)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*!&amp;lt; Bit position for RTC_CR_OSCE. */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;#define HW_RTC_CR_ADDR(x)&amp;nbsp;&amp;nbsp;&amp;nbsp; ((x) + 0x10U)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;#define BW_RTC_CR_OSCE(x, v) (BITBAND_ACCESS32(HW_RTC_CR_ADDR(x), BP_RTC_CR_OSCE) = (v))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;void k22f_enable_rtc() {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG style="color: #e23d39; font-size: 10pt;"&gt;&amp;nbsp; // Enable 32.768 kHz oscillator&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG style="color: #e23d39; font-size: 10pt;"&gt;// The following is the offending line... Ported from KSDK 1.0.0&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG style="color: #e23d39; font-size: 10pt;"&gt;&amp;nbsp; BW_RTC_CR_OSCE(RTC, 1);&amp;nbsp; //or RTC_BWR_CR_OSCE(RTC, 1)&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; // Wait 100ms for oscillator output to settle down&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; OSA_TimeDelay(100);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;/*&amp;nbsp; // Disable time counters TSR and TPR before writing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; RTC_BWR_SR_TCE(RTC, 0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; // Clear the RTC_TPR counter&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; HW_RTC_TPR_CLR(RTC, 0xFFFFFFFFU);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; // Write the RTC_TSR with 0 second value&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; RTC_WR_TSR(RTC, 0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; // Enable time counters TSR and TPR after writing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; RTC_BWR_SR_TCE(RTC, 1); */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; last_sec = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; last_tpr = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; last_total_ms = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the result.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Screenshot (70).png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/31689iB9A9681826F60036/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (70).png" alt="Screenshot (70).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 02 Jul 2016 01:24:15 GMT</pubDate>
    <dc:creator>cwati</dc:creator>
    <dc:date>2016-07-02T01:24:15Z</dc:date>
    <item>
      <title>Enabling Oscillator is causing unhandled interrupt</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528862#M32802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm trying to port my code from KSDK 1.0.0 to KSDK 1.3.0, using KDS 3.0.0.&amp;nbsp; Device is MK22FN256xxx12.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We need a precise timer in the ms, which means we can't use "OSA_TimeGetMsec()" since it's drifting too much.&amp;nbsp; In KSDK 1.0.0 we manually set the RTC registers and read them.&amp;nbsp; But when I tried to port the code to KSDK 1.3.0, whenever I write 1 to the CR OSCE it will trigger some sort of "&lt;SPAN style="color: #222222; font-family: 'Times New Roman', serif; font-size: 16px;"&gt;WDOG_EWM_IRQHandler()" or &lt;/SPAN&gt;Default ISR.&lt;/P&gt;&lt;P&gt;Seems like I'm missing something here... any help is appreciated... Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the piece of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #909090; font-size: 10pt;"&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; #define BP_RTC_CR_OSCE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (8U)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*!&amp;lt; Bit position for RTC_CR_OSCE. */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;#define HW_RTC_CR_ADDR(x)&amp;nbsp;&amp;nbsp;&amp;nbsp; ((x) + 0x10U)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;#define BW_RTC_CR_OSCE(x, v) (BITBAND_ACCESS32(HW_RTC_CR_ADDR(x), BP_RTC_CR_OSCE) = (v))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;void k22f_enable_rtc() {&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG style="color: #e23d39; font-size: 10pt;"&gt;&amp;nbsp; // Enable 32.768 kHz oscillator&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG style="color: #e23d39; font-size: 10pt;"&gt;// The following is the offending line... Ported from KSDK 1.0.0&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG style="color: #e23d39; font-size: 10pt;"&gt;&amp;nbsp; BW_RTC_CR_OSCE(RTC, 1);&amp;nbsp; //or RTC_BWR_CR_OSCE(RTC, 1)&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; // Wait 100ms for oscillator output to settle down&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; OSA_TimeDelay(100);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;/*&amp;nbsp; // Disable time counters TSR and TPR before writing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; RTC_BWR_SR_TCE(RTC, 0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; // Clear the RTC_TPR counter&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; HW_RTC_TPR_CLR(RTC, 0xFFFFFFFFU);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; // Write the RTC_TSR with 0 second value&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; RTC_WR_TSR(RTC, 0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; // Enable time counters TSR and TPR after writing&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; RTC_BWR_SR_TCE(RTC, 1); */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; last_sec = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; last_tpr = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;&amp;nbsp; last_total_ms = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-size: 10pt; color: #909090;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the result.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Screenshot (70).png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/31689iB9A9681826F60036/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (70).png" alt="Screenshot (70).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Jul 2016 01:24:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528862#M32802</guid>
      <dc:creator>cwati</dc:creator>
      <dc:date>2016-07-02T01:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling Oscillator is causing unhandled interrupt</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528863#M32803</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 don't think that the PE generated or KSDK code respects all real-world cases where the RTC may already be operating and have interrupts enabled. There was a problem with the PE generated code that caused issues as detailed here: &lt;A _jive_internal="true" href="https://community.nxp.com/message/515197#comment-515197" title="https://community.nxp.com/message/515197#comment-515197"&gt;https://community.nxp.com/message/515197#comment-515197&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When enabling/re-enabling the RTC I would first check whether it is already running since it is a waste of time to restart it and wait if it is already operating. In addition it is always best to temporarily disable its operation to avoid it generating interrupts before you are ready for them. Use RTC_SR = 0; to do this before the initialisation code (but after the RTC module's clocks have been applied).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Jul 2016 12:17:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528863#M32803</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2016-07-03T12:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling Oscillator is causing unhandled interrupt</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528864#M32804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cecylia Wati,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; From your description, it seems you didn't enable the RTC clock gate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please add this code before your RTC register configuration:&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM_SCGC6|= SIM_SCGC6_RTC_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Please test it on your side, if you still have question, please kindly let me know!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;/P&gt;&lt;P&gt;Jingjing&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, 04 Jul 2016 07:32:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528864#M32804</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2016-07-04T07:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling Oscillator is causing unhandled interrupt</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528865#M32805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! This seems to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Jul 2016 23:55:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Enabling-Oscillator-is-causing-unhandled-interrupt/m-p/528865#M32805</guid>
      <dc:creator>cwati</dc:creator>
      <dc:date>2016-07-04T23:55:39Z</dc:date>
    </item>
  </channel>
</rss>

