cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0 Stop 1 with wake on event

Carl_G
Senior

I'm trying to do something that seems simple if you go a search. I want the module to sleep. Then I will wake it with voltage on pin B6. I don't want an interrupt. Just an event. People mix event and interrupt so much and all the examples I see are based on interrupt so its nearly impossible to find any that actually are about events.

From what I can see it should be very simple. But my module does not sleep. It wakes immediately.

hack of my sleep code

 

{
GPIO_InitTypeDef GPIO_InitStruct = {0};
adcDeInit();
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; /* Configures: EXTI_EXTICRx, RTSR1, FTSR1, EMR1, IMR1*/
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_SuspendTick();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFE);
}

 

From what I have read the module should be in STOP1 mode now. But what I see is it just enters and immediately exits. I don't see any flags set in RPR1 or FPR1. Should I?

Note: This module has UCPD and UART and other clocks that I have not turned off. EMR1 = 0x40; IMR1 = 0xFFFC0000; but interrupt should not wake the MCU only event right?

 

 

5 REPLIES 5
Carl_G
Senior

adding __disable_irq(); at the start makes it work. But IRQ are not supposed to wake the MCU from WFE!?

TDK
Guru

Is SEVONPEND=0?

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

Yes

Carl_G_0-1740772840323.png

 

Carl_G
Senior

PWM output based on TIM2 is still active so I guess that means the MPU isn't really getting into STOP mode. Maybe the debug in stop mode feature is conspiring with TIM to keep the MPU somewhat awake. I thought TIM would stop on its own, but it seems not. Without the debugger the same behavior. TIM is still going.

Further testing. TIM is running 4x slower. I think that means the PLL is off but HSI16 is still there. RM says some peripherals can enable HSI16 during stop mode. It seems that is what is happening. System clock is HSI16 as per RM.

Carl_G
Senior

And now its working. No discernable changes. Just works as expected. Not even disabling interrupts. Sleeps then wakes on GPIO... It keeps saying "debug in low power mode" even on just a program, but I think that is a bug because it does not behave as if that feature is still on since debugger will disconnect.