<?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中的主题 KE02Z SetCallback IAR tools not working</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KE02Z-SetCallback-IAR-tools-not-working/m-p/326787#M15063</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm doing a project that uses FTM2 for a variety of timing functions, and having finally worked through some noob startup issues, thought I had a good handle on using the FTM's.&lt;/P&gt;&lt;P&gt;However - I have set up my FTM2 for two capture channels, and one compare channel, set the clock to /4, and used the FTM_SetCallback function to tell the code where the ISR should be for FTM2&lt;/P&gt;&lt;P&gt;interrupts.&lt;/P&gt;&lt;P&gt;Unfortunately, the code keeps going to the default ISR, instead of my ISR code, and I can't figure out why. I used essentially identical code to set up the ISR on a different project, and it works just fine.&lt;/P&gt;&lt;P&gt;I'm not sure where to look, as I do not have the familiarity to know where to look. I can see that my code calls the SetCallback function, but cannot access whatever data are being passed.&lt;/P&gt;&lt;P&gt;Here's what I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FTM_InputCaptureInit(FTM2,FTM_CHANNEL_CHANNEL0,FTM_INPUTCAPTURE_RISINGEDGE);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_InputCaptureInit(FTM2,FTM_CHANNEL_CHANNEL1,FTM_INPUTCAPTURE_RISINGEDGE);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_OutputCompareInit(FTM2,FTM_CHANNEL_CHANNEL2,0); /* FTM2 CH2 is virtual tooth count */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_EnableOverflowInt(FTM2); // allow overflow interrupts&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; /* set clock source and start the counter */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_ClockSet(FTM2, FTM_CLOCK_SYSTEMCLOCK, FTM_CLOCK_PS_DIV4); // 200ns period&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; /* set MOD value */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_SetModValue(FTM2,0);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* set callback function for ISR */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_SetCallback(FTM2, FTM2_Task);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM_ClrChannelFlag(FTM2, FTM_CHANNEL_CHANNEL0);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM_ClrChannelFlag(FTM2, FTM_CHANNEL_CHANNEL1);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Allow FTM2 interrupts now */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NVIC_EnableIRQ(FTM2_IRQn);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My ISR function is pretty long, so I've just put the first few lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* FTM2_Task handles crank input on channel 0, cam input on channel 1,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;virtual tooth count on channel 2. Overflow is last */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void FTM2_Task(void)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; static uint32_t perDifference;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; static uint16_t tempValue;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; static uint16_t FTM1_Value;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; static union tempRpm&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; twoInt rpmStruct;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t rpmLong;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; }tempRpm; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; if (FTM_GetChannelFlag(FTM2, 0)) // if channel 0, crank int&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a series of "if" statements that look for the various interrupt flags. However, this function is never accessed, even though if I halt my code, I can see that the interrupt bits for FTM2 are correctly set. I found that all FTM2 interrupts were going instead to the default ISR handler in "vectors.c".&lt;/P&gt;&lt;P&gt;If there are any IAR gurus who might be able to help here, I'd appreciate it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Dec 2014 04:07:46 GMT</pubDate>
    <dc:creator>davetelling</dc:creator>
    <dc:date>2014-12-05T04:07:46Z</dc:date>
    <item>
      <title>KE02Z SetCallback IAR tools not working</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KE02Z-SetCallback-IAR-tools-not-working/m-p/326787#M15063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm doing a project that uses FTM2 for a variety of timing functions, and having finally worked through some noob startup issues, thought I had a good handle on using the FTM's.&lt;/P&gt;&lt;P&gt;However - I have set up my FTM2 for two capture channels, and one compare channel, set the clock to /4, and used the FTM_SetCallback function to tell the code where the ISR should be for FTM2&lt;/P&gt;&lt;P&gt;interrupts.&lt;/P&gt;&lt;P&gt;Unfortunately, the code keeps going to the default ISR, instead of my ISR code, and I can't figure out why. I used essentially identical code to set up the ISR on a different project, and it works just fine.&lt;/P&gt;&lt;P&gt;I'm not sure where to look, as I do not have the familiarity to know where to look. I can see that my code calls the SetCallback function, but cannot access whatever data are being passed.&lt;/P&gt;&lt;P&gt;Here's what I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FTM_InputCaptureInit(FTM2,FTM_CHANNEL_CHANNEL0,FTM_INPUTCAPTURE_RISINGEDGE);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_InputCaptureInit(FTM2,FTM_CHANNEL_CHANNEL1,FTM_INPUTCAPTURE_RISINGEDGE);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_OutputCompareInit(FTM2,FTM_CHANNEL_CHANNEL2,0); /* FTM2 CH2 is virtual tooth count */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_EnableOverflowInt(FTM2); // allow overflow interrupts&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; /* set clock source and start the counter */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_ClockSet(FTM2, FTM_CLOCK_SYSTEMCLOCK, FTM_CLOCK_PS_DIV4); // 200ns period&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; /* set MOD value */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_SetModValue(FTM2,0);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* set callback function for ISR */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; FTM_SetCallback(FTM2, FTM2_Task);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM_ClrChannelFlag(FTM2, FTM_CHANNEL_CHANNEL0);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FTM_ClrChannelFlag(FTM2, FTM_CHANNEL_CHANNEL1);&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Allow FTM2 interrupts now */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NVIC_EnableIRQ(FTM2_IRQn);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My ISR function is pretty long, so I've just put the first few lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* FTM2_Task handles crank input on channel 0, cam input on channel 1,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;virtual tooth count on channel 2. Overflow is last */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void FTM2_Task(void)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; static uint32_t perDifference;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; static uint16_t tempValue;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; static uint16_t FTM1_Value;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; static union tempRpm&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; twoInt rpmStruct;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t rpmLong;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; }tempRpm; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; if (FTM_GetChannelFlag(FTM2, 0)) // if channel 0, crank int&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a series of "if" statements that look for the various interrupt flags. However, this function is never accessed, even though if I halt my code, I can see that the interrupt bits for FTM2 are correctly set. I found that all FTM2 interrupts were going instead to the default ISR handler in "vectors.c".&lt;/P&gt;&lt;P&gt;If there are any IAR gurus who might be able to help here, I'd appreciate it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 04:07:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KE02Z-SetCallback-IAR-tools-not-working/m-p/326787#M15063</guid>
      <dc:creator>davetelling</dc:creator>
      <dc:date>2014-12-05T04:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: KE02Z SetCallback IAR tools not working</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KE02Z-SetCallback-IAR-tools-not-working/m-p/326788#M15064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dave Telling,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest referring demos comes with FRDM-K20Z, the demos are available at:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-KE02Z40M&amp;amp;parentCode=KE02_40&amp;amp;fpsp=1&amp;amp;nodeId=01624698C90DE4" title="http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-KE02Z40M&amp;amp;parentCode=KE02_40&amp;amp;fpsp=1&amp;amp;nodeId=01624698C90DE4"&gt;Freescale Freedom Development Platform for Ki|Freescale&lt;/A&gt;&lt;/P&gt;&lt;P&gt;please click "Get started with the FRDM-KE02Z40M and IAR EWARM" on the right bottom of the above page.&lt;/P&gt;&lt;P&gt;After extract the package, you will see there is an FTM-DEMO. it should helps on your issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 05:41:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KE02Z-SetCallback-IAR-tools-not-working/m-p/326788#M15064</guid>
      <dc:creator>Rick_Li</dc:creator>
      <dc:date>2014-12-05T05:41:01Z</dc:date>
    </item>
  </channel>
</rss>

