cancel
Showing results for 
Search instead for 
Did you mean: 

How to config SYS_WKUP3 for STM32L4 MCU Standby mode?

Dick Lin
Senior

Hi,

I am setting up STM32L4 for standby mode. From Cube and NUCLEO-L496ZG\Examples\PWR\PWR_SLEEP\Src the GPIO pin is PE6.

However I don't see any Cube generated code to init this pin. Neither in example code.

Should I init the PE6 as GPIO input pin?

Thx

GPIO_InitStruct.Pin = GPIO_PIN_6;

GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = GPIO_PULLUP;

HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

8 REPLIES 8

The example uses PC.13 (the user button)

Defined in

STM32Cube_FW_L4_V1.12.0\Drivers\BSP\STM32L4xx_Nucleo_144\stm32l4xx_nucleo_144.h

Initialized in

STM32Cube_FW_L4_V1.12.0\Drivers\BSP\STM32L4xx_Nucleo_144\stm32l4xx_nucleo_144.c

Also note the button makes to VDD, and the pin configured as Input, pull-down

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

Hi Clive,

I have following code modify for PE6 running Nucleo-144. However I am unable to breakpoint into EXTI15_10_IRQHandler() function.

Looking the code below, it setup the PE6 and EXTI15_10_IRQHandler but there is no connection between those two.

How can I setup the GPIO PE6 to EXTI15_10_IRQHandler?

Thx

 else if (ButtonMode == BUTTON_MODE_EXTI)

 {

  /* Configure Button pin as input with External interrupt */

  GPIO_InitStruct.Pin = BUTTON_PIN[Button];

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;

  HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);

  /* Enable and set Button EXTI Interrupt to the lowest priority */

  HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);

  HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));

 }

You'd use EXTI9_5_IRQHandler

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

Don't see this EXTI9_T_IRQHandler working.

Also strange for PE6, it's value always 1 even I connect to GND.

Thx

Evidently not doing something right.

Check schematic and connectivity. Check clocks

Use debugger, inspect all related registers.

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

I missed the clock enable code. for GPIOE.

 __HAL_RCC_GPIOE_CLK_ENABLE();

But now I get 0 all the time for PE6.

Checking the user's manual, seems PE6 in CN9 is assigned to SAI_1_A. Not sure if I can use for SYS_WKUP3 although I am not using SAI.

If not how can we test SYS_WKUP3 on Nucleo-144 board?

Thx

PE6 should be usable for this purpose.

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

Why there is a need to init GPIO pin different way for MODE_GPIO and MODE_EXTI?

What I need for this SYS_WKUP3 is whenever the GPIO value change interrup service routine will be called. In this case should I only have EXTI mode?

Thx

void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)

{

 GPIO_InitTypeDef GPIO_InitStruct;

 /* Enable the BUTTON Clock */

 BUTTONx_GPIO_CLK_ENABLE(Button);

 if (ButtonMode == BUTTON_MODE_GPIO)

 {

  /* Configure Button pin as input */

  GPIO_InitStruct.Pin = BUTTON_PIN[Button];

  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

  GPIO_InitStruct.Pull = GPIO_PULLDOWN;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

  HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);

 }

 else if (ButtonMode == BUTTON_MODE_EXTI)

 {

  /* Configure Button pin as input with External interrupt */

  GPIO_InitStruct.Pin = BUTTON_PIN[Button];

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;

  HAL_GPIO_Init(BUTTON_PORT[Button], &GPIO_InitStruct);

  /* Enable and set Button EXTI Interrupt to the lowest priority */

  HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);

  HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));

 }

}