AnsweredAssumed Answered

Kinetist K64 FlexTimer Interrupt Questions

Question asked by Designer11 on Mar 29, 2017
Latest reply on Mar 31, 2017 by Designer11

Hi All,

I'm trying to understand how to activate the FTM3 overflow Interrupt handlers on the Kinetis K64 microcontroller. I'm able to generate the waveforms for both channels 4 and 5 of the  FTM3.  Everywhere i read it keeps saying i need to add my interrupt handler function name to the "kinetis_sysinit.c" file, located in the startup folder. However, i'm unable to locate such a file anywhere. The closest files i came across that mentioned about interrupt handlers are  either vector.c or vector.h. Below is my test codes on the overflow, but it failed mto work. I'm using KDS IDE for this development.


void FTM3_IRQHandler()
     if (FTM3_SC & FTM_SC_TOF_MASK){
          FTM3_SC&=0x7F; //clear TOF bit
          timer_overflow = 0x01;
          pulses_cnt +=1;
byte pulse_motor(void)

     static word count_pulse = 0x00;
     static pulse_motors pulse_state = INIT_PULSE_DATA;

     switch (pulse_state)
     case INIT_PULSE_DATA:
#if 1
           * For FTM 3 channel 4, J1.7  and 5, J1.9  on Port C

          SIM_SCGC3|=0x2000000; //enable FTM3 module clock
          FTM3_CONF=0xC0; //set up BDM in 11
          FTM3_FMS=0x00; //clear the WPEN so that WPDIS is set in FTM0_MODE register
          FTM3_MODE|=0x05; //enable write the FTM CnV register
          FTM3_C4SC=0x68; //edge-alignment, PWM initial state is High, becomes low, enable interrupt only on channel 4
          FTM3_SC=0x08; //PWM edge_alignment, system clock driving, dividing by 1
          pulse_state = EXECUTE_PULSE_DATA;
#if 1
          if (pulses_cnt ==500){
               pulses_cnt = 0x00;
          //pulses_cnt = num_pulses;
          pulse_state= INIT_PULSE_DATA;

Could anyone point me to where i'm doing this wrong ?