Even with including this file the definitions aren't reconized....ozcar wrote: Tue Oct 18, 2022 12:53 am Perhaps you need some #include in your code, like maybe for stm32l0xx_hal_lptim.h?
How use LPTIM
Re: How use LPTIM
Re: How use LPTIM
In fact HAL_LPTIM_MODULE_ENABLED is not enabled by default. you can add an hal_conf_extra.h file with:
to enable it.
In this archive, you will get a port of a STM32Cube project for L4:
https://github.com/STMicroelectronics/S ... lseCounter
I've tested and it works as expected.
Code: Select all
#define HAL_LPTIM_MODULE_ENABLED
In this archive, you will get a port of a STM32Cube project for L4:
https://github.com/STMicroelectronics/S ... lseCounter
I've tested and it works as expected.
Re: How use LPTIM
A big thanks for the answerfpiSTM wrote: Tue Oct 18, 2022 5:16 pm In fact HAL_LPTIM_MODULE_ENABLED is not enabled by default. you can add an hal_conf_extra.h file with:
to enable it.Code: Select all
#define HAL_LPTIM_MODULE_ENABLED
In this archive, you will get a port of a STM32Cube project for L4:
https://github.com/STMicroelectronics/S ... lseCounter
LPTIM_PusleCounter.zip
I've tested and it works as expected.
I tested it (Nucleo L432KC) but there is a small issue.
To see the led toogle i need to add the MspInit
Code: Select all
if (HAL_LPTIM_Init(&LptimHandle) != HAL_OK)
{
Error_Handler();
}
HAL_LPTIM_MspInit(&LptimHandle);
Do you have an idea ?
Re: How use LPTIM
in the run mode, lots of ways to do this.try the normal Hardware Timers
in the stop mode, you will need something that can wake up the chip. in this particular case, the timer is 16 bit wide (23 bit with the prescaler). so for multiple minutes, you will need to be prepared to wake up multiple times and keep track of it.
luckily this timer has a compare function so you can advance it like this:
Code: Select all
calculate the desired number of cycles to achive your duration
calculate the number of wake-ups required (essentially desired cycle mod timer width)
compare register = current timer value + desired cycle
put the chip to sleep
//in the interrupt
if (wake-up counter--) {blink the led; reset wake-up counter / compare register}
else go back to sleep
Re: How use LPTIM
if the timer didn't have the compare register, the work flow is slightly differernt: you will need to load up the timer with an offset (= -desired cycles, for an up counter).
this approach will have long-term errors however.
this approach will have long-term errors however.
Re: How use LPTIM
HAL_LPTIM_MspInit is called by HAL_LPTIM_Init so I don't see why you need to call it again.hamady91 wrote: Tue Oct 18, 2022 7:23 pmA big thanks for the answerfpiSTM wrote: Tue Oct 18, 2022 5:16 pm In fact HAL_LPTIM_MODULE_ENABLED is not enabled by default. you can add an hal_conf_extra.h file with:
to enable it.Code: Select all
#define HAL_LPTIM_MODULE_ENABLED
In this archive, you will get a port of a STM32Cube project for L4:
https://github.com/STMicroelectronics/S ... lseCounter
LPTIM_PusleCounter.zip
I've tested and it works as expected.
I tested it (Nucleo L432KC) but there is a small issue.
To see the led toogle i need to add the MspInit
but i see no change in the frequency of the LED blinking when i whange the div of the prescalerCode: Select all
if (HAL_LPTIM_Init(&LptimHandle) != HAL_OK) { Error_Handler(); } HAL_LPTIM_MspInit(&LptimHandle);
Do you have an idea ?
https://github.com/stm32duino/Arduino_C ... tim.c#L293
The project I've ported is for Nucleo L476RG. Maybe some init are different for L432. You can refers to the project of the L432 board:
https://github.com/STMicroelectronics/S ... lseCounter
One other thing is the L432 is a Nucleo32 and I know sometimes it is not easy to properly configure it from hardware view due to the number of SB used to be able to support different feature.