cancel
Showing results for 
Search instead for 
Did you mean: 

Waking up STM32L0 from LPTIM interrupt

Ash G
Associate II
Posted on July 13, 2018 at 03:12

I'm trying to put STM32L0 into a low power sleep mode. I want it to sleep for 9.5s and wake up for 0.5s. Once it's awake it needs to switch on LEDs, check for any interrupts from a Lora radio module and process the data which cannot be done inside an interrupt routine. I'm using LPTIM interrupts to wake up the system. STM32 Workbench and CubeMX have been used for development. My question is where I should implement the tasks that need to be done once its awake?

/* LPTIMER interrrupt will be used to wakeup the system from SLEEP mode. */

/* Clear  LPTIM to be sure there is no ongoing interrupt of line */

//TODO:

/* Enable the power down mode during Sleep mode */

__HAL_FLASH_SLEEP_POWERDOWN_ENABLE();

//Disable all interrupts except for LPTIM interrupt

/* Suspend Tick increment to prevent wakeup by Systick interrupt. */

/* Otherwise the Systick interrupt will wake up the device within 1ms */

/* (HAL time base). */

HAL_SuspendTick();

/* Enter Sleep Mode , wake up is done once LPTimer interrupt occured */

HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);

/* Resume Tick interrupt if disabled prior to sleep mode entry */

HAL_ResumeTick();

HAL_Delay(500);

Inside an initialisation function, I'm starting the low power timer. 

/* Set the Maximum value of the counter (Auto-Reload) that defines the Period */

#define LPTIM_Period (uint32_t) 43938

/* Set the Timeout value */

#define LPTIM_Timeout (uint32_t) (21969 - 1)

if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIM_Period, LPTIM_Timeout) != HAL_OK)

{

Error_Handler();

}
1 REPLY 1

@ST Community​ any FAEs covering L0 and LPTIM?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..