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:
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:
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:
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?
Hello sloat,
After check your code , please check the "install interrupts" , then try again.
If it still can not work well , you can send your project to me, then it can find the
problem facility with debug .
Hope it helps
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Have a great day,
Alice