AnsweredAssumed Answered

Having trouble with TPM interrupt in output compare mode on FRDM-KL03Z with KSDK

Question asked by ken.sloat on Dec 2, 2015
Latest reply on Dec 4, 2015 by Alice_Yang

Hello,

 

On the FRDM-KL03Z I'm having trouble with the TPM interrupt. I have used processor expert to configure TPM0 to run at 125 KHz in Output Compare Mode (with no pin output) with a Match Value of 125 (in order to generate a 1 ms interrupt). I have setup my PE options as follows:

 

Selection_184.png

 

Selection_185.png

 

With the following basic code to verify since the interrupt wasn't firing:

 

  uint32_t foo = 0, foo2 = 0;

  TPM_DRV_CounterStart(general_timer_IDX, kTpmCountingUp, 65535U,false);

  while(1)

  {

      foo2 = TPM_DRV_CounterRead(general_timer_IDX);

      if(foo2 >= 125)

      {

          foo = 0;

      }

  }

 

Interrupt function is in another file like this:

 

PE_ISR(general_timer_IRQHandler) {

    soundBuzzer();

    TPM_DRV_IRQHandler(general_timer_IDX);

}

 

I am finding that the interrupt is not firing, but the timer is running properly ( I can see the value increment and I did some timing experiments with if statement). When I check the different TPM status registers after it is equal to or has passed 125 (match value) I see the following:

 

Selection_187.png

 

Which means a couple of things, according to the datasheet, with TPM0_STATUS I should see a bit set when a channel event occurs, and obviously you see there is none. Also, I would think that TPM0_C0SC should have the MS & ELS bits set (4:2) and none are set, which would mean that according to the datasheet it would appear to be in "Channel Disabled" and not "Software Compare" like I think it should be:

Selection_189.png

 

The following routines are being called (which they should be since the checkbox is checked to intialize the timer):

 

void Components_Init(void)

{

 

  /*! LED_GPIO_CONTROL Auto initialization start */

  GPIO_DRV_Init(gpio2_InpConfig0,LED_GPIO);

  /*! LED_GPIO_CONTROL Auto initialization end */

 

  /*! OTHER_GPIO_CONTROL Auto initialization start */

  GPIO_DRV_Init(OTHER_GPIO_CONTROL_InpConfig0,OTHER_GPIO_CONTROL);

  /*! OTHER_GPIO_CONTROL Auto initialization end */

 

  /*! general_timer Auto initialization start */

  NVIC_SetPriority(TPM0_IRQn, 0U);

  TPM_DRV_Init(general_timer_IDX, &timer);

  TPM_DRV_SetClock(general_timer_IDX, kTpmClockSourceModuleClk, kTpmDividedBy32);

  TPM_DRV_OutputCompareEnable(general_timer_IDX, 0U, kTpmOutputNone, 125, 65535U, true);

  /*! general_timer Auto initialization end */

 

I my example code I also start the timer manually since this isn't done by the OutputCompareEnable function.

 

 

Anways, not sure what is going on here, what am I missing?

Outcomes