I'm trying to use LPTMR to create a 1ms periodic interrupt for a bare metal simple scheduler. I'm programming for NXP's S32K144 using S32DS for ARM, with the S32K14x RTM SDK for GCC, version 2.0.0 (not the beta).
I have already added the LPTMR component to my project, and used component inspector to adjust a timer configuration to suit. Right now, the config is as below:
Code:
-------------------
const lptmr_config_t lpTmr1_config0 = {
.workMode = LPTMR_WORKMODE_TIMER,
.dmaRequest = false,
.interruptEnable = true,
.freeRun = false,
.compareValue = 1000U,
.counterUnits = LPTMR_COUNTER_UNITS_MICROSECONDS,
.clockSelect = LPTMR_CLOCKSOURCE_RTC,
.prescaler = LPTMR_PRESCALE_4_GLITCHFILTER_2,
.bypassPrescaler = false,
.pinSelect = LPTMR_PINSELECT_TRGMUX,
.pinPolarity = LPTMR_PINPOLARITY_RISING,
};
-------------------
Also, I have created a custom LPTMR0_IRQHandler() function;
And I have added some timer setup code to main():
Code:
-------------------
LPTMR_DRV_Init(INST_LPTMR1, &lpTmr1_config0, TRUE);
LPTMR_DRV_SetInterrupt(INST_LPTMR1, TRUE);
-------------------
However, while debugging, it seems that the interrupt handler is never executed.
What am I missing here?
Also, do I need to clear anything in LPTMR registers before leaving the ISR?
Best regards,
Joao
Hi Joao,
There is an SDK example that shows how to use it.
Have you enabled the interrupt in the NVIC registers using:
Yes, you need to clear the CSR_TCF flag.
Regards,
Daniel
Right on the spot!
Both the interrupt enable at setup and the compare flag clearing, in the interrupt handler, were missing. Added them, and now I have a minimalistic baremetal scheduler running.
I'm using the interrupt vectors already in place on flash, so the INT_SYS_InstallHandler part was not needed.
Really nice, thank you for your time and attention.
Best regards,
Joao