Using LPTMR for system time base inspite of OSA

cancel
Showing results for 
Search instead for 
Did you mean: 

Using LPTMR for system time base inspite of OSA

360 Views
lokuate
Contributor III

I'm migrating a bare metal project from KL15 to KL17, I use LPTMR in KL15 for my time-base and low power mode.

 

Now I see that KL17 has a OSA consuming LPTMR, how can I hang my system time-base to LPTMR inspite of OSA?

 

(Sorry, I'm not quite well versed with all that RTOS mumbo jumbo).

 

Thank you,

C

Labels (1)
0 Kudos
3 Replies

49 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Carlos:

Sorry for the time with no response.

You are right that the OSA layer uses the LPTMR for its APIs such as OSA_TimeDelay(). However if you do not require any OSA, then you can make use of the LPTMR for your custom time-base as long as you do not call any of the OSA functions requiring timing. The next version of KSDK (v1.2) will have the option to release the LPTMR from the OSA so you can use it for your application.

If you experience any issues please let us know.


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

49 Views
angusgalloway-b
NXP Employee
NXP Employee

Hey Jorge,

In KSDK 1.2, how can I have the OSA generate an interrupt driven 1ms timer?

I setup my application using the LPTMR to essentially tick time every ms. I would now want the OSA_TimeDelay() feature, but OSA_Init sets up the LPTMR differently than how I'm using it. Specifically OSA_Init selects the 1kHz LPO clock as the source which isn't fast enough for a 1ms clock (it gets divided by two). Obviously I can call OSA_Init first and then overwrite its settings with my own, but that would likely result in unpredictable behaviour.

Is there a way of changing the OSA to generate a 1ms clock though the API (I don't see one), or should I ditch the LPTMR as the basis of my application's 1ms clock and use something else like the PIT.

Thanks,

Angus

0 Kudos

49 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Angus:

Actually the OSA_Init() sets the LPTMR prescaler to bypassed, see below:

pastedImage_0.png

So the actual counter frequency is 1 kHz. You can enable LPTMR interrupts from your application after OSA_Init() and from the ISR function increment the compare value by 1 with LPTMR_HAL_SetCompareValue().

I guess this approach should work, although I don't think sharing LPTMR for both OSA and application is ideal.

Regards!

Jorge Gonzalez