<?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>topic How do get capture interrupt working on FRDM-KE02 board? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-do-get-capture-interrupt-working-on-FRDM-KE02-board/m-p/358763#M18064</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I confess - I'm a total noob at this ARM stuff - but it seems that someone has made it as confusing as possible to get anything done!&lt;/P&gt;&lt;P&gt;I am trying to do something that should be pretty simple - I just want to use FTM0, channel 0 to capture the rising edge of a signal on PTA0, and when the interrupt occurs,&lt;/P&gt;&lt;P&gt;toggle PTB0.&lt;/P&gt;&lt;P&gt;So far, I have this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* timer_test_3.c tests various timer interrupt &amp;amp; counting functions */&lt;/P&gt;&lt;P&gt;#include "common.h"&lt;/P&gt;&lt;P&gt;#include "ics.h"&lt;/P&gt;&lt;P&gt;#include "ftm.h"&lt;/P&gt;&lt;P&gt;#include "sysinit.h"&lt;/P&gt;&lt;P&gt;#include "gpio.h"&lt;/P&gt;&lt;P&gt;#include "sim.h"&lt;/P&gt;&lt;P&gt;/* not used right now&lt;/P&gt;&lt;P&gt;typedef struct&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint8_t Port0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint8_t Port1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint8_t Port2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint8_t Port3;&lt;/P&gt;&lt;P&gt;} fourBytes;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;typedef struct&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; uint16_t dbyte0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; uint16_t dbyte1;&lt;/P&gt;&lt;P&gt; } twoDbyte;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static union {&lt;/P&gt;&lt;P&gt;&amp;nbsp; fourBytes portBytes;&lt;/P&gt;&lt;P&gt;&amp;nbsp; twoDbyte port16;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint32_t portWord;&lt;/P&gt;&lt;P&gt;}PORTA; */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void FTM0_Task(void);&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;&lt;/P&gt;&lt;P&gt;sysinit();&lt;/P&gt;&lt;P&gt;//SIM-&amp;gt;SCGC |= SIM_SCGC_FTM0_MASK; // gate clock to FTM0&lt;/P&gt;&lt;P&gt;FTM_InputCaptureInit(FTM0,FTM_CHANNEL_CHANNEL0,FTM_INPUTCAPTURE_RISINGEDGE);&lt;/P&gt;&lt;P&gt;FTM_ClockSet(FTM0, FTM_CLOCK_SYSTEMCLOCK, FTM_CLOCK_PS_DIV2);&lt;/P&gt;&lt;P&gt;FTM_SetCallback(FTM0,FTM0_Task);&lt;/P&gt;&lt;P&gt;NVIC_EnableIRQ(FTM0_IRQn);&lt;/P&gt;&lt;P&gt;FTM_EnableChannelInt(FTM0,FTM_CHANNEL_CHANNEL0);&lt;/P&gt;&lt;P&gt;GPIOA-&amp;gt;PDDR = 0xfffffffe; /* all ones except PTA0 for outputs */&lt;/P&gt;&lt;P&gt;&amp;nbsp; while (1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&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;/* Input capture interrupt */&lt;/P&gt;&lt;P&gt;void FTM0_Task(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; GPIOA-&amp;gt;PTOR = 0x00000100; // PTB0&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I try to step through this, it goes through to the line that sets the clock to a divide by 2. If I click the "step" button again, the system never reaches the FTM_SetCallback line, it just keeps looping to the default_ISR location.&lt;/P&gt;&lt;P&gt;Note that I have commented out the original SIM setting to gate th eclock, as it appears to be embedded in the InputCaptureInit function.&lt;/P&gt;&lt;P&gt;If I comment out the FTM_SetCallback line (which I am assuming, is SUPPOSED to tell the compiler that I have an interrupt routine labeled FTM0_Task) and comment out the FTM)_Task, the program will run, sort of, in that the counter counts,&lt;/P&gt;&lt;P&gt;but obviously no interrupt. I have worked on this for hours, and cannot get past this roadblock.&lt;/P&gt;&lt;P&gt;Can someone show, very simply, how to do what I'm trying to do, or point out the obvious error in my code? I'm using the IAR toolset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Nov 2014 00:38:00 GMT</pubDate>
    <dc:creator>davetelling</dc:creator>
    <dc:date>2014-11-21T00:38:00Z</dc:date>
    <item>
      <title>How do get capture interrupt working on FRDM-KE02 board?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-do-get-capture-interrupt-working-on-FRDM-KE02-board/m-p/358763#M18064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I confess - I'm a total noob at this ARM stuff - but it seems that someone has made it as confusing as possible to get anything done!&lt;/P&gt;&lt;P&gt;I am trying to do something that should be pretty simple - I just want to use FTM0, channel 0 to capture the rising edge of a signal on PTA0, and when the interrupt occurs,&lt;/P&gt;&lt;P&gt;toggle PTB0.&lt;/P&gt;&lt;P&gt;So far, I have this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* timer_test_3.c tests various timer interrupt &amp;amp; counting functions */&lt;/P&gt;&lt;P&gt;#include "common.h"&lt;/P&gt;&lt;P&gt;#include "ics.h"&lt;/P&gt;&lt;P&gt;#include "ftm.h"&lt;/P&gt;&lt;P&gt;#include "sysinit.h"&lt;/P&gt;&lt;P&gt;#include "gpio.h"&lt;/P&gt;&lt;P&gt;#include "sim.h"&lt;/P&gt;&lt;P&gt;/* not used right now&lt;/P&gt;&lt;P&gt;typedef struct&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint8_t Port0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint8_t Port1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint8_t Port2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint8_t Port3;&lt;/P&gt;&lt;P&gt;} fourBytes;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;typedef struct&lt;/P&gt;&lt;P&gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; uint16_t dbyte0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; uint16_t dbyte1;&lt;/P&gt;&lt;P&gt; } twoDbyte;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static union {&lt;/P&gt;&lt;P&gt;&amp;nbsp; fourBytes portBytes;&lt;/P&gt;&lt;P&gt;&amp;nbsp; twoDbyte port16;&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint32_t portWord;&lt;/P&gt;&lt;P&gt;}PORTA; */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void FTM0_Task(void);&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;&lt;/P&gt;&lt;P&gt;sysinit();&lt;/P&gt;&lt;P&gt;//SIM-&amp;gt;SCGC |= SIM_SCGC_FTM0_MASK; // gate clock to FTM0&lt;/P&gt;&lt;P&gt;FTM_InputCaptureInit(FTM0,FTM_CHANNEL_CHANNEL0,FTM_INPUTCAPTURE_RISINGEDGE);&lt;/P&gt;&lt;P&gt;FTM_ClockSet(FTM0, FTM_CLOCK_SYSTEMCLOCK, FTM_CLOCK_PS_DIV2);&lt;/P&gt;&lt;P&gt;FTM_SetCallback(FTM0,FTM0_Task);&lt;/P&gt;&lt;P&gt;NVIC_EnableIRQ(FTM0_IRQn);&lt;/P&gt;&lt;P&gt;FTM_EnableChannelInt(FTM0,FTM_CHANNEL_CHANNEL0);&lt;/P&gt;&lt;P&gt;GPIOA-&amp;gt;PDDR = 0xfffffffe; /* all ones except PTA0 for outputs */&lt;/P&gt;&lt;P&gt;&amp;nbsp; while (1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&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;/* Input capture interrupt */&lt;/P&gt;&lt;P&gt;void FTM0_Task(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; GPIOA-&amp;gt;PTOR = 0x00000100; // PTB0&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I try to step through this, it goes through to the line that sets the clock to a divide by 2. If I click the "step" button again, the system never reaches the FTM_SetCallback line, it just keeps looping to the default_ISR location.&lt;/P&gt;&lt;P&gt;Note that I have commented out the original SIM setting to gate th eclock, as it appears to be embedded in the InputCaptureInit function.&lt;/P&gt;&lt;P&gt;If I comment out the FTM_SetCallback line (which I am assuming, is SUPPOSED to tell the compiler that I have an interrupt routine labeled FTM0_Task) and comment out the FTM)_Task, the program will run, sort of, in that the counter counts,&lt;/P&gt;&lt;P&gt;but obviously no interrupt. I have worked on this for hours, and cannot get past this roadblock.&lt;/P&gt;&lt;P&gt;Can someone show, very simply, how to do what I'm trying to do, or point out the obvious error in my code? I'm using the IAR toolset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 00:38:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-do-get-capture-interrupt-working-on-FRDM-KE02-board/m-p/358763#M18064</guid>
      <dc:creator>davetelling</dc:creator>
      <dc:date>2014-11-21T00:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do get capture interrupt working on FRDM-KE02 board?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-do-get-capture-interrupt-working-on-FRDM-KE02-board/m-p/358764#M18065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Dave,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code is too complicated, for you call the driver of FTM. Based on your requirement, I develop a simple example to write register directly, it is straightforward. connect the captured to PTA0, you will see the toggling of PTB0 pin.&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;XiangJun Rong&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 08:38:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-do-get-capture-interrupt-working-on-FRDM-KE02-board/m-p/358764#M18065</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2014-11-21T08:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do get capture interrupt working on FRDM-KE02 board?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-do-get-capture-interrupt-working-on-FRDM-KE02-board/m-p/358765#M18066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xiangjun,&lt;/P&gt;&lt;P&gt;Thank you for the code sample. I will examine it and see if ti resolves my problems.&lt;/P&gt;&lt;P&gt;Dave Telling&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Nov 2014 15:22:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-do-get-capture-interrupt-working-on-FRDM-KE02-board/m-p/358765#M18066</guid>
      <dc:creator>davetelling</dc:creator>
      <dc:date>2014-11-21T15:22:55Z</dc:date>
    </item>
  </channel>
</rss>

