cancel
Showing results for 
Search instead for 
Did you mean: 

Modified LPTIM_PWM_LSE demo does not work as expected with LPTIM2

Geoffrey Davis
Associate
Posted on July 05, 2017 at 20:45

With the STM32L476ZGT6 Evaluation board, which I've just started to use, I tried the LPTIM_PWM_LSE demo successfully (after modifying timer frequency to make LED blink at 1Hz). I then attempted to change the demo to use LPTIM2 instead. I noted that this did not produce the same result as for LPTIM1 where the LED would blink until Wkup/Tamper was triggered - the LED just stays on.

main.c changes:

1) RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM2;

2) RCC_PeriphCLKInitStruct.Lptim2ClockSelection = RCC_LPTIM2CLKSOURCE_LSE;

3) LptimHandle.Instance = LPTIM2;

4) HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);  (instead of STOP2, since LPTIM2 doesn't work in STOP2)

stm32l4xx_hal_msp changes:

1) Changed 'LPTIM1' to 'LPTIM2' for all functions containing 'LPTIM1' in the name

2) GPIO_InitStruct.Alternate = GPIO_AF14_LPTIM2;

Any insights into why I cannot substitute LPTIM2 for LPTIM1 in this demo?

Thanks!

#lptim
1 ACCEPTED SOLUTION

Accepted Solutions
Zt Liu
Senior III
Posted on July 07, 2017 at 12:24

Are you using PB2 for LPTIM2?!

PB2 can only be mapped to LPTIM1_OUT not for LPTIM2_OUT!

Try PA4, PA8 and PD13 for LPTIM2.

Please take a look at Datasheet, it's always healthy to check it.

0690X00000607QbQAI.png0690X00000607SuQAI.png

View solution in original post

2 REPLIES 2
Zt Liu
Senior III
Posted on July 07, 2017 at 12:24

Are you using PB2 for LPTIM2?!

PB2 can only be mapped to LPTIM1_OUT not for LPTIM2_OUT!

Try PA4, PA8 and PD13 for LPTIM2.

Please take a look at Datasheet, it's always healthy to check it.

0690X00000607QbQAI.png0690X00000607SuQAI.png
Posted on July 07, 2017 at 17:29

Thanks for clarifying the limitations on LPTIM2 output. As you suspected, I was trying to do something impossible. I had downloaded all the documentation from the STM32L476G-EVAL product page, and had the STM32L4x6 Reference Manual but not the specific datasheet for the STM32L476xx, so I was missing information on LPTIM2_OUT. I was able to get the LPTIM2 demo to work outputting to PA4 without a problem, confirming the pulse with a logic analyzer.

I just tried out the STM32CubeMX application and wished that I had done so before, since it clearly highlighted the possible LPTIM2 outputs.