AnsweredAssumed Answered

How do get capture interrupt working on FRDM-KE02 board?

Question asked by Dave Telling on Nov 20, 2014
Latest reply on Nov 21, 2014 by Dave Telling

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!

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,

toggle PTB0.

So far, I have this:



/* timer_test_3.c tests various timer interrupt & counting functions */

#include "common.h"

#include "ics.h"

#include "ftm.h"

#include "sysinit.h"

#include "gpio.h"

#include "sim.h"

/* not used right now

typedef struct


  uint8_t Port0;

  uint8_t Port1;

  uint8_t Port2;

  uint8_t Port3;

} fourBytes;


typedef struct


   uint16_t dbyte0;

   uint16_t dbyte1;

} twoDbyte;


static union {

  fourBytes portBytes;

  twoDbyte port16;

  uint32_t portWord;

}PORTA; */


void FTM0_Task(void);


int main (void)




//SIM->SCGC |= SIM_SCGC_FTM0_MASK; // gate clock to FTM0






GPIOA->PDDR = 0xfffffffe; /* all ones except PTA0 for outputs */

  while (1)






/* Input capture interrupt */

void FTM0_Task(void)


  GPIOA->PTOR = 0x00000100; // PTB0



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.

Note that I have commented out the original SIM setting to gate th eclock, as it appears to be embedded in the InputCaptureInit function.

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,

but obviously no interrupt. I have worked on this for hours, and cannot get past this roadblock.

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.