<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic FRDM_KL02Z TPM0 Timer Overflow Interrupt not working. in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-TPM0-Timer-Overflow-Interrupt-not-working/m-p/1834114#M66207</link>
    <description>&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;I'm using the fsl_tpm.h driver.&lt;/P&gt;&lt;P&gt;here is the initTimer() code that setups up TPM0_IRQHandler().&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#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(&amp;amp;tpmConfig);
    tpmConfig.prescale = kTPM_Prescale_Divide_128;

    NVIC_SetPriority(TPM0_IRQn, 3);
    NVIC_EnableIRQ(TPM0_IRQn);

    TPM_Init(TPM0, &amp;amp;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 &amp;lt;&amp;lt; BOARD_INITPINS_LED_RED_PIN);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Mar 2024 01:45:46 GMT</pubDate>
    <dc:creator>SoloTheDog</dc:creator>
    <dc:date>2024-03-25T01:45:46Z</dc:date>
    <item>
      <title>FRDM_KL02Z TPM0 Timer Overflow Interrupt not working.</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-TPM0-Timer-Overflow-Interrupt-not-working/m-p/1834114#M66207</link>
      <description>&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;I'm using the fsl_tpm.h driver.&lt;/P&gt;&lt;P&gt;here is the initTimer() code that setups up TPM0_IRQHandler().&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#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(&amp;amp;tpmConfig);
    tpmConfig.prescale = kTPM_Prescale_Divide_128;

    NVIC_SetPriority(TPM0_IRQn, 3);
    NVIC_EnableIRQ(TPM0_IRQn);

    TPM_Init(TPM0, &amp;amp;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 &amp;lt;&amp;lt; BOARD_INITPINS_LED_RED_PIN);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 01:45:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-TPM0-Timer-Overflow-Interrupt-not-working/m-p/1834114#M66207</guid>
      <dc:creator>SoloTheDog</dc:creator>
      <dc:date>2024-03-25T01:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM_KL02Z TPM0 Timer Overflow Interrupt not working.</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-TPM0-Timer-Overflow-Interrupt-not-working/m-p/1838284#M66227</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Pls set the TOIE bit in TPMx_SC reg as the following Fig:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1711940626222.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/271270i9258820656768D18/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1711940626222.png" alt="xiangjun_rong_0-1711940626222.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suppose that the bit can be initialized by the structure&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-c"&gt;&lt;CODE&gt;tpmConfig&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 03:06:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDM-KL02Z-TPM0-Timer-Overflow-Interrupt-not-working/m-p/1838284#M66227</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2024-04-01T03:06:13Z</dc:date>
    </item>
  </channel>
</rss>

