cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F091VCT6 Exit from standby is not working.

BKath
Associate II

We have used PE6 GPIO for STM32 standby entry and PE6 is configured as initially as EXTI input mode in pull-down configuration. When there is high to low transition on PE6 STM32 jumps to standby mode. We are also using the same GPIO for coming out form standby mode because same pin is used as wakeup source but STM32 does not wakeup from standby mode during low to high transition on PE6.

We have also checked with Eval board sample code same happens with that STM32 jumps to standby mode but does not wakeup.

As we are planning to test our product for battery back up time.

We require that when STM32 jumps to standby mode it will switched on battery power and after rising EXTI on PE6 STM32 should wakeup.

Thanks,

Brijesh.

6 REPLIES 6

Hi

Is PE6 configured as wakeup pin 3 on PWR_CSR register (EWUP3 bit) ?

BKath
Associate II

Yes PE6 configured as wakeup pin 3 on PWR_CSR register (EWUP3 bit). Please see our below code and let us know if we miss anything.

/* Enable Power Clock*/

 __HAL_RCC_PWR_CLK_ENABLE();

  HAL_PWR_DisableSleepOnExit( );

  /* The Following Wakeup sequence is highly recommended prior to each Standby mode entry

mainly when using more than one wakeup source this is to not miss any wakeup event.

 - Disable all used wakeup sources,

 - Clear all related wakeup flags,

 - Re-enable all used wakeup sources,

 - Enter the Standby mode.

  */

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN3);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN4);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN5);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN6);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN7);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN8);

  /* Clear PWR wake up Flag */

  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);

  /* Enable WKUP pin */

  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN3);

  /* Request to enter STANDBY mode */

  HAL_PWR_EnterSTANDBYMode();

Kamesh Mehta
Associate II

Hello Brijesh,

We also have same problem.

When our device switches power from AC lines to battery power we receive an interrupt on GPIO and we put the device in deep sleep.

Code snippet to put the code in deep sleep

In External interrupt handler

//Disable all interrupts first

IRQn_Type eIRQ;

uint8_t ui8TotalIRQ = CEC_CAN_IRQn; /* this is the last element of IRQn_Type*/

RTC_alarmDisable();

DMA_deInit();

ADC_deInit();

UART_deInit();

SPI_deInit();

I2C_deInit();

TIM_deInit();

for(eIRQ = 0; eIRQ <= ui8TotalIRQ; eIRQ++)

{

if( eIRQ != RTC_IRQn /*&& eIRQ != EXTI4_15_IRQn*/)

{

HAL_NVIC_ClearPendingIRQ(eIRQ);

HAL_NVIC_DisableIRQ(eIRQ);

}

}

// Then we configure the GPIO PE6 (which is wake up source 3) as an interrupt input device

GPIO_InitStruct.Pin = PFail_Pin;

 GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;

 GPIO_InitStruct.Pull = GPIO_PULLDOWN;

 HAL_GPIO_Init(PFail_GPIO_Port, &GPIO_InitStruct);

//Then we go into sleep mode with almost same routine as yours

  HAL_PWR_DisableSleepOnExit();  

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN3);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN4);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN5);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN6);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN7);

  HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN8);

  /* Clear PWR wake up Flag */

  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);

  /* Enable WKUP pin */

  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN3);

  /* Request to enter STANDBY mode */

  HAL_PWR_EnterSTANDBYMode();

We are able to go into deep sleep successfully but we are not able to receive the wake up interrupt even after configuring it. Once we press reset button then and only then micro controller wakes up.

To detect whether board was into deep sleep mode we have inserted below snippet in main

if(__HAL_PWR_GET_FLAG(PWR_FLAG_WU) != RESET)

 {

 HAL_GPIO_WritePin(LED1_GPIO_Port,LED1_Pin,GPIO_PIN_RESET);

 HAL_Delay(1000);

 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

//If pfail pin (PE6 which is wakeup source 3 is not 1 then board was woken up by another method so go to sleep again)

 if(GPIO_PIN_RESET == HAL_GPIO_ReadPin(PFail_GPIO_Port,PFail_Pin))

 {

 PWR_EnterSTANDBYMode();

 }

 }

 if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)

 {

 HAL_GPIO_WritePin(LED2_GPIO_Port,LED2_Pin,GPIO_PIN_RESET);

 HAL_Delay(1000);

 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);

 }

We observe here as the LED2 glows up after i press the reset button to get the board out of deep sleep to forcefully wake up the board.

The LED1 "NEVER" glows up which means we do not receive the "Wake UP" event in controller, but when we check same PIN on DSO we see a low to high transition.

I hope it you get some help from my code snippet.

I am also hoping that someone else from community can solve my problem here.

Kamesh Mehta
Associate II

Update!!

We are using bootloader in the code

Hi

Code seems ok.

I found an interesting point in Datasheet. Shouldn't be written.

Try to Wake Up the MCU with PA0 pin, if works need further investigation..

0690X000008B8jdQAC.jpg

BKath
Associate II

Hi Vangelis Fortounas

Thanks for your response.

Also checked keeping PA0 pin as wake-up source but still MCU does not wake up.

Any other suggestions please?