cancel
Showing results for 
Search instead for 
Did you mean: 

LPTIM interrupt

Goran Mahovlic
Associate II
Posted on November 02, 2017 at 10:08

Is it possible to set LPTIM to have interrupt every ms?

I did try some examples, and got PWM working with LPTIM on PB2.

I can do that with TIM2, but then I got problem with system wake up, and I do not want that...

4 REPLIES 4
Posted on November 02, 2017 at 11:16

You did not tell us what model you have in mind, but yes, LPTIM generally can trigger an interrupt, and 1ms is well within its capabilities, if there's a reasonable clock source. In the LPTIM chapter in RM there's a LPTIM interrupts subchapter, read that.

I don't understand the rest of your question: interrupt *means* processor wakeup, how else would you service that interrupt?

JW

Goran Mahovlic
Associate II
Posted on November 02, 2017 at 11:32

It is STM32L082

Im using cubemx code for lora .

Im trying to add some interrupt without messing to much with code and state machine.

So LPTIM will act the same and wake processor if I use interrupt like TIM2 does?

I just want to some simple stuff in that interrupt, toggle led and add counter.

Now with TIM2 I need to use HAL_PWR_EnableSleepOnExit to go back into SLEEP/STOP mode after finishing interrupt

I just want to do the same with maybe lower power consumption.

I will check RM again.

Posted on November 02, 2017 at 18:36

Using an STM32L072 (ie 082 less AES), that looks to support an LPTIM interrupt, you might have to play games with the clock sources so they don't power down, but I'd imagine WFI will work the same for LPTIM as it would with TIM2.

And presumably there is also SysTick..

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on November 03, 2017 at 16:56

Yes it needs playing

Yes I did source clock from LSE, and divider is set to 128.

I did manage to get interrupts that does not mess with LoRa state machine, but it is working strange.

I have tested LP PWM and when I use it to generate PWM it consumes 4uA.

If I use it as LP PWM_IT it consumes 200uA and generate IT every 10ms.

If I connect PWM pin (in my case PB2) to other pin that has RISING edge interrupt I get all I need (10ms interrupt) and consumptions is 4uA - 5uA.

So maybe Im doing something wrong or LP IT is doing something strange.

Anyway for now I working solution with 2 pins extra ...