<?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のトピックK60 Flextimer Interrupt</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550430#M33489</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;I am using TWR-K60N512, with PK60DN512Z VMD10 chip. I'm trying to use the interrupt to update FTM0_C0V value when the FTM0 timer overflows but my program keeps getting suspended.&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;I have enabled the interrupt vector for FTM0, by adding this line "enable_irq(62);" in the main code. The interrupt vector assignment was found from Chapter 3 in the K60P144M100SF2RM reference manual. I have also enabled timer over flow interrupt 'FTM0_SC |= FTM_SC_TOIE_MASK;' .&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;This is what my ISR.h looks like:&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P&gt;#ifndef __ISR_H&lt;/P&gt;&lt;P&gt;#define __ISR_H 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#undef&amp;nbsp; VECTOR_78&lt;/P&gt;&lt;P&gt;#define VECTOR_78 FTM0_isr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// ISR(s) are defined in your project directory.&lt;/P&gt;&lt;P&gt;extern void FTM0_isr(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#endif&amp;nbsp; //__ISR_H&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what my interrupt function looks like, it is in the main source code. I have declared the function prototype in the main code too:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void FTM0_isr(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; static unsigned short brightness = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; static bool increase = true;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (FTM0_SC &amp;amp; 0x80) // if FTM counter exceeds MOD count.&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (brightness == 60000)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; increase = false;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else if (brightness == 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; increase = true;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if(increase)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; brightness++;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; brightness--;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; FTM0_SC &amp;amp;= 0x7F; // clear TOF flag&lt;/P&gt;&lt;P&gt;&amp;nbsp; FTM0_C0V = brightness;&lt;/P&gt;&lt;P&gt;&amp;nbsp; FTM0_PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; &lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My program was suspended whenever I run it and points to the following function in 'kinetis_sysinti.c' :&lt;/P&gt;&lt;P&gt;void isr_default(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; __asm("bkpt");&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Write your interrupt code here ... */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea how to troubleshoot this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Jul 2016 06:14:42 GMT</pubDate>
    <dc:creator>broccolee</dc:creator>
    <dc:date>2016-07-08T06:14:42Z</dc:date>
    <item>
      <title>K60 Flextimer Interrupt</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550430#M33489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;I am using TWR-K60N512, with PK60DN512Z VMD10 chip. I'm trying to use the interrupt to update FTM0_C0V value when the FTM0 timer overflows but my program keeps getting suspended.&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;I have enabled the interrupt vector for FTM0, by adding this line "enable_irq(62);" in the main code. The interrupt vector assignment was found from Chapter 3 in the K60P144M100SF2RM reference manual. I have also enabled timer over flow interrupt 'FTM0_SC |= FTM_SC_TOIE_MASK;' .&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;This is what my ISR.h looks like:&lt;/P&gt;&lt;P style="font-size: 14px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;&lt;/P&gt;&lt;P&gt;#ifndef __ISR_H&lt;/P&gt;&lt;P&gt;#define __ISR_H 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#undef&amp;nbsp; VECTOR_78&lt;/P&gt;&lt;P&gt;#define VECTOR_78 FTM0_isr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// ISR(s) are defined in your project directory.&lt;/P&gt;&lt;P&gt;extern void FTM0_isr(void);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#endif&amp;nbsp; //__ISR_H&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what my interrupt function looks like, it is in the main source code. I have declared the function prototype in the main code too:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void FTM0_isr(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; static unsigned short brightness = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; static bool increase = true;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (FTM0_SC &amp;amp; 0x80) // if FTM counter exceeds MOD count.&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (brightness == 60000)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; increase = false;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else if (brightness == 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; increase = true;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if(increase)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; brightness++;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; brightness--;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; FTM0_SC &amp;amp;= 0x7F; // clear TOF flag&lt;/P&gt;&lt;P&gt;&amp;nbsp; FTM0_C0V = brightness;&lt;/P&gt;&lt;P&gt;&amp;nbsp; FTM0_PWMLOAD |= FTM_PWMLOAD_LDOK_MASK; &lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My program was suspended whenever I run it and points to the following function in 'kinetis_sysinti.c' :&lt;/P&gt;&lt;P&gt;void isr_default(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; __asm("bkpt");&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Write your interrupt code here ... */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea how to troubleshoot this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 06:14:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550430#M33489</guid>
      <dc:creator>broccolee</dc:creator>
      <dc:date>2016-07-08T06:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: K60 Flextimer Interrupt</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550431#M33490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Dao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I believe may be happening here is that the MCU is going to a predefined "default" ISR function. You'll need to overwrite this default function by naming your ISR function the same thing. It should then recognize your function as the new "default" ISR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if I were using the flextimer on the K21F120MA, and want interrupts on faults, overflows, and channel interrupts, then I would look in the "startup_MK21FA12.s" for the IRQ handler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After some looking, I've found FTMx_IRQHandler, which means that if I make a function with the same name, then it should override the default ISR function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;BR /&gt;Charles&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 17:23:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550431#M33490</guid>
      <dc:creator>charlesasquith</dc:creator>
      <dc:date>2016-07-08T17:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: K60 Flextimer Interrupt</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550432#M33491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Charles, it works now! I looked at the 'kinetis_sysinit.c' and nothing has been specified at all in the interrupt vector table. For instance, the vectors are all named: UASSIGNED_ISR. So I replaced the appropriate vector with my FTM_isr function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 21:41:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550432#M33491</guid>
      <dc:creator>broccolee</dc:creator>
      <dc:date>2016-07-08T21:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: K60 Flextimer Interrupt</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550433#M33492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great! Glad I could help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Charles&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jul 2016 21:53:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K60-Flextimer-Interrupt/m-p/550433#M33492</guid>
      <dc:creator>charlesasquith</dc:creator>
      <dc:date>2016-07-08T21:53:47Z</dc:date>
    </item>
  </channel>
</rss>

