FRDM_KL02Z TPM0 Timer Overflow Interrupt not working.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

FRDM_KL02Z TPM0 Timer Overflow Interrupt not working.

352件の閲覧回数
SoloTheDog
Contributor I

All of the registers seem to be set properly, and the TOF register is properly set when the timer overflows. I can poll it and manually clear it in main, but the TPM0_IRQHandler() doesn't get called. I tried the SDK example that uses the same interrupt and it also doesn't work, so don't think it is an issue in code. What else can I look at to get this working?

I'm using the fsl_tpm.h driver.

here is the initTimer() code that setups up TPM0_IRQHandler().

 

 

#include "fsl_tpm.h"
#include "timer.h"
#include "fsl_gpio.h"
#include "pin_mux.h"
#include "stdio.h"

void initTimer()
{
    tpm_config_t tpmConfig;
    TPM_GetDefaultConfig(&tpmConfig);
    tpmConfig.prescale = kTPM_Prescale_Divide_128;

    NVIC_SetPriority(TPM0_IRQn, 3);
    NVIC_EnableIRQ(TPM0_IRQn);

    TPM_Init(TPM0, &tpmConfig);

    uint32_t tpmClock = TPM_SOURCE_CLOCK;
    uint32_t timerPeriod = USEC_TO_COUNT(1000U, tpmClock) / 128; // 1ms

    TPM_EnableInterrupts(TPM0, kTPM_TimeOverflowInterruptEnable);

    TPM_SetTimerPeriod(TPM0, timerPeriod);
    TPM_StartTimer(TPM0, kTPM_SystemClock);
}

volatile uint32_t elapsedTime = 0;

void TPM0_IRQHandler()
{
    TPM_ClearStatusFlags(TPM0, kTPM_TimeOverflowFlag);
    GPIO_PortToggle(BOARD_INITPINS_LED_RED_GPIO, 1u << BOARD_INITPINS_LED_RED_PIN);
}

 

 

 

0 件の賞賛
返信
1 返信

318件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Pls set the TOIE bit in TPMx_SC reg as the following Fig:

xiangjun_rong_0-1711940626222.png

 

I suppose that the bit can be initialized by the structure

tpmConfig

Hope it can help you

BR

XiangJun Rong

0 件の賞賛
返信