Skip to main content
MWisi.1
Associate II
December 2, 2021
Question

LPTIM cnt Initialize

  • December 2, 2021
  • 8 replies
  • 1464 views

I am using the low power timer (LPTIM), but i need to initialize the timer value to 30000 before start the counting.

Is it possible ?

Thank you!

This topic has been closed for replies.

8 replies

TDK
December 2, 2021

Yes:

LPTIM1->CNT = 30000;

You can do this prior to using HAL_TIM_Base_Start() HAL_LPTIM_*_Start if you're using HAL since the function doesn't touch the counter.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MWisi.1
MWisi.1Author
Associate II
December 3, 2021

hi @TDK​ 

I had done

LPTIM1->CNT = 30000;

But, i hadnt used the HAL_TIM_Base_Start()!

I will try then tomorrow this sequence!

LPTIM1->CNT = 30000;

HAL_TIM_Base_Start(&s_TimerInstance);

Can i always repete this sequence in at any point in the program and repeat it ?

Because i will receive a LoRaWAN message that contains this LPTIM1 value.

I will have to change the LPTIM1 many times

Thanks

TDK
December 3, 2021
Yes you can change the counter during execution. If you’re interested in the details, read through the timer section of the reference manual.
"If you feel a post has answered your question, please click ""Accept as Solution""."
MWisi.1
MWisi.1Author
Associate II
December 3, 2021

Did you see that is not writable the lptim counter ?

MWisi.1
MWisi.1Author
Associate II
December 3, 2021

hi,

can you send a example setting the LPTIM1 counter value ?

Thanks!

TDK
December 3, 2021

My first reply does this...

"If you feel a post has answered your question, please click ""Accept as Solution""."