cancel
Showing results for 
Search instead for 
Did you mean: 

LPTIM cnt Initialize

MWisi.1
Associate II

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!

8 REPLIES 8
TDK
Guru

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
Associate II

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

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
Associate II

Did you see that is not writable the lptim counter ?

MWisi.1
Associate II

hi,

can you send a example setting the LPTIM1 counter value ?

Thanks!

My first reply does this...

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

If you are brand new, perhaps look at some examples which use the timer. Here are some results from searching:

https://github.com/STMicroelectronics/STM32CubeG4/search?q=MX_LPTIM1_Init

You need to use HAL_LPTIM_* functions to interface with LPTIM timers, not HAL_TIM_* as I wrote previously.

Good luck.

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

Hi, i had tried that but got compiler error!

0693W00000GZxD4QAL.png