I'm hoping to setup more than one timers in the system we're developing such that one will be 1 seconds tick while others or in milliseconds tick, etc.
I've imported the lptmr SDK project, which uses LPTMR0 & manipulated it a little bit to do what I need for use in 4 factors, some in seconds, and counting to minutes, with lowest time in seconds.
Since MKL28Z claims to have both LPTMR0 and LPTMR1, I tried swapping everything in this imported simple lptmr project from lptmr0 to lptmr1 values, e.g. based register address, interrupt #, interrupt handler pointer.
I know I replaced all in the definitions but the rest of the function calls and configuration settings I kept AS IT IS for lptmr0 also in lptmr1.
PROBLEM: In using lptmr1, it hangs... it does not behave or do anything as how it did when using lptmr0.
Are these 2 interchangeable?
I noticed this though on MKL28Z7.h which I'm not sure effects the problem:
<partial quote of device interrupts>
LPTMR0_IRQn = 26, /**< LPTMR0 interrupt */
RTC_Seconds_IRQn = 27, /**< RTC seconds */
INTMUX0_0_IRQn = 28, /**< INTMUX0 channel 0 interrupt */
INTMUX0_1_IRQn = 29, /**< INTMUX0 channel 1 interrupt */
INTMUX0_2_IRQn = 30, /**< INTMUX0 channel 2 interrupt */
INTMUX0_3_IRQn = 31, /**< INTMUX0 channel 3 interrupt */
LPTMR1_IRQn = 32, /**< LPTMR1 interrupt (INTMUX source IRQ0) */
Notice LPTMR0_IRQn = 26, solely for lptmr0 interrupt. However, LPTMR1_IRQn = 32 is "shared" with INTMUX source IRQ0.
I'm not sure which in this project triggers IRQ0 & if so could that be what's causing lptmr1 not to work?
Worst comes to worst, and I'm just stuck with LPTMR0, since I can declare a config structure, e.g.
Can I declare several such lptmr_config data structures and just vary each by the prescaler value for each structure so some ticks in seconds while others are faster in milliseconds or such? E.g.
config->prescalerClockSource = kLPTMR_PrescalerClock_1; // or _0 thru _3
>>> Addition: Also if I only use LPTMR0 with several data configured timer structures, how do I know which triggered the LPTMR0_IRQHandler()? inside the interrupt handler? The problem I have with MKL28Z is I don't see any "timer handle" or "timer label" to know which triggered what, like we do it in other MCU's.
Or maybe someone knows how that is done in MKL28Z? because I don't.
>>> More addition: In further studing the lptmr SDK project example, I see that it setup the time period (called LPTMR_SetTimerPeriod()) once for a single lptmr data config structure. Does that mean I can only also setup for ONE (1) timer data structure & run one lptmr0 timer in the system only at a time? And in order to refine to ticks in milliseconds I should use other PrescalerClock that's not 1 second but use the faster milliseconds divider & just do "counters" to "simulate" which completed 100 millisecond vs. 1 second vs. 10 minutes, etc?
Thanks for the help.