Zym Dap

STM32L0 Stop Mode with COMP wake-up

Discussion created by Zym Dap on Apr 14, 2018
Latest reply on Apr 16, 2018 by Tilen MAJERLE

Hello colleagues!

 

I'm trying to implement Stop Mode example from the latest FW  (v1.10.0) to my STM32L053C8 uC. Now I'm totally lost how to enter Stop mode and wake up ONLY by using my COMP2 pin (interrupt mode) properly... I'd like to wake up my uC with photodiode by using 2nd uC comparator with Vrefint enabled (IT Rising interrupt).

 

if(MyStopModeFlag == 1){

 

/* Configure the system Power */
SystemPower_Config();
HAL_SuspendTick();

/* Enter Stop Mode */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

/* Configures system clock after wake-up from STOP: enable HSE, PLL and select
PLL as system clock source (HSE and PLL are disabled in STOP mode) */
SystemClockConfig_STOP();
HAL_ResumeTick();
MyStopModeFlag = 0;
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
}

 

 

But the problem is that in my project I'm using an ADC, UART (both DMA), I2C channels and some I/O GPIOs... These are the Init functions:

static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_I2C1_Init(void);
static void MX_COMP2_Init(void);
static void MX_ADC_Init(void);

 

How should I disable them all except the COMP2? Maybe it's enought to disable all the IRQs and leave only the COMP2 IRQ? Maybe it is possible to "play" only with Init and DeInit functions to achieve my goal? Maybe I can somehow use COMP event and wait for event in my code?

 

Any ideas appreciated!

Outcomes