cancel
Showing results for 
Search instead for 
Did you mean: 

LOW power timers in stm32g0

Rohit007
Associate III

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.

2 REPLIES 2
TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".
Andrew Neil
Super User

@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...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.