2017-07-05 11:45 AM
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!
#lptimSolved! Go to Solution.
2017-07-07 03:24 AM
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.
2017-07-07 03:24 AM
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.
2017-07-07 10:29 AM
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.