2025-10-07 6:12 AM - last edited on 2025-10-07 7:14 AM by Andrew Neil
Hi,
I am working on STM32G0c1RET6 board and i want to understand the working of low power timer (LPTIM) in stop mode.
i am using the HAL_LPTIM_Counter_Start_IT(&hlptim1, 65534) to enable LPTIM1 and print a value in function
void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim) {
if (hlptim->Instance == LPTIM1) {/* If instance called for HEATER DRIVER */
printf("1\r\n");
}
}
is it the correct way to print the value. because at some places i have seen using
HAL_LPTIM_TimeOut_Start_IT() function. which one is correct ??
Edited to apply source code formatting - please see How to insert source code for future reference.
2025-10-07 6:46 AM
HAL_LPTIM_Counter_Start_IT will start the counter and printf, if configured correctly, will print text.
Note that in STOP 0 or STOP 1 mode, the CPU is not running. It will have to wake up to execute code.
2025-10-07 7:18 AM
@Rohit007 wrote:is it the correct way to print the value
In general, it's not a good idea to be calling printf from an interrupt handler - especially if you have implemented your printf over a slow interface like UART.
@Rohit007 wrote:at some places i have seen using HAL_LPTIM_TimeOut_Start_IT() function
Where have you seen that? Please give a link...