AnsweredAssumed Answered

How do I setup a flextimer overflow interrupt function?

Question asked by Dan Kendall on May 5, 2015
Latest reply on Sep 1, 2015 by Dan Kendall

Hi,

 

I have a question regarding setting up an interrupt function to be called when a FlexTimer overflow occurs.  I want to use the FlexTimer 0 to call the Flex0_ISR function everytime the timer overflows, but the interrupt function is not being called.  From what I can tell, the timer is running, as I see CNT register increasing, and I believe the interrupt should be firing at the FlexTimer level (SC->TOF and SC->TOIE are both set to 1).  I am sure I am overlooking something or enabling the incorrect interrupt.

 

Thanks.

 

 

This is code I am using:

 

 

//Interrupt function prototype

static void    Flex0_ISR (pointer);

 

void cmsis_task(uint_32 node_num)

{

  _mqx_uint mqxIntReturn;

 

  //Setup the interrupt

  _int_install_isr(NVIC_FlexTimer0, Flex0_ISR, NULL);

  mqxIntReturn =  _bsp_int_init(NVIC_FlexTimer0, 7, 0, TRUE);

 

  //Enable the clock to the FlexTimer 0

  CCM_CCGR1 |= CCM_CCGR1_CG8(0x3); //FTM0 clock is on during all modes, except stop mode (0x03)

  CCM_CSCMR2 = (CCM_CSCMR2 & CCM_CSCMR2_FTM0_EXT_CLK_SEL_MASK) | CCM_CSCMR2_FTM0_EXT_CLK_SEL(2);

  CCM_CSCDR1 |= CCM_CSCDR1_FTM0_CLK_EN_MASK;

 

  //Setup FlexTimer 0

  FTM0_MOD = 83;

  FTM0_CNT = 0x0; //Reset counter to zero

  FTM0_CNTIN = 0; //Set the Counter Initial Value to 0

 

  //Set FTM 0 Clock Source to System Clock, and Prescaler to / 1

  FTM0_SC = FTM_SC_CLKS(1) | FTM_SC_PS(0) | FTM_SC_TOIE_MASK;

 

  //Ensure the M4 can access the FlexTimer 0 interrupt

  MSCM_BASE_PTR->IRSPRC42 = 0x03;

}

 

int doFlexOnce = 0;

 

//Interrupt function

static void Flex0_ISR(pointer parameter)

{

  if(doFlexOnce == 0)

  {

  doFlexOnce++;

  }

}

Outcomes