I have to use a timer to get a real time counter for my application.
I started from KSDK_1.3.0/iar lptmr driver example code to get a sample code.
My need is to have a count period at least egal to 26ms.
In LPTMR example driver/ main.c,
I have selected .prescalerClockSource = kClockLptmrSrcOsc0erClk, as source clock. Timer LSB is so 1µs.
To get 26ms for the timer period, I called LPTMR_DRV_SetTimerPeriodUs(LPTMR_INSTANCE,26000);
But that was not working.
With that code I can configure the timer for a maximum count period of 16,383ms!!!
I had a look to the status reported by settimerperiod function and it was kStatus_LPTMR_TimerPeriodUsTooLarge!!!
In fsl_lptmr_driver.c , lptmr_status_t LPTMR_DRV_SetTimerPeriodUs(uint32_t instance, uint32_t us), there is a some code to verify tick_count
before to calling LPTMR_HAL_SetCompareValue(base, tick_count - 1);
It verifies that tick_count is smaller than 16bits but the compare value in LPTMR_HAL_SetCompareValue(LPTMR_Type * base, uint32_t compareValue)
is 32bits width!!!
I changed the code like that in fsl_lptmr_driver.c:
/* CMR register is 32 Bits */
if (tick_count > 0xFFFFFFFFU)
And now it works fine!! :))