cancel
Showing results for 
Search instead for 
Did you mean: 

PA0 WakeUp from Deep stop unreliable on STM32WL31

sbelcatronic
Associate III

Good day.

 

I am using STM32WL31 on a custom board.

DeepStop mode entry works correctly, but wakeup from PA0 (WakeUp pin) is not reliable or does not work. I used the example code in project:

STM32Cube_FW_WL3_V1.3.1\Projects\NUCLEO-WL33CC\Examples\PWR\PWR_DEEPSTOP

The same code I use in my custom board works correctly on NUCLEO-WL33CC2 board (I have tested succefull the code on the NUCLEO-WL33CC2). In my opinion the difference from my custom bord + my code and the NUCLEO-WL33CC2 is the microcontroller; the NUCLEO-WL33CC2 mount the STM32WL33, my board mount the STM32WL31.

 

Code sequence foe enter in deep stop:

1. Enable wakeup pin (PA0, PA11 used as wakeup pins are connected by a button to GND). Internal pull-up enabled using LL_PWR_EnableGPIOPullUp on PA0 e PA11

2. Clear WUF flags

3. Enter DeepStop

 

When I press PA0 or PA11 buttons the MCU does not resume execution OR behaves inconsistently, it look like as the micro is in an undefined state.

After programmed the micro it seam to enter in deep stop and when I press the wakeup pin it exit from deep stop, execute the main and go back in deep stop. If I wakeup again by the IO pin it not exit from deep stop but look like in an udefined state.

 

In this conversation:

https://community.st.com/t5/stm32-mcus-wireless/stm32wl31-fails-to-exit-deepstop-from-rtc-wakeup/m-p/887400#M27790

The user marvdm report a similar behaver on the same MCU (STM32WL31)

 

This is my main.c:

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* Configure the peripherals common clocks */
  PeriphCommonClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
//  MX_GPIO_Init();
//  MX_TIM2_Init();
//  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */

  GPIO_InitTypeDef GPIO_InitStruct = {0};
//
//  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
//
//  /*Configure GPIO pins : OUT_FREQUENCE_SELECT_Pin RE_485_Pin DE_485_Pin DL3_Pin
//                           DEBUG_1_Pin DL2_Pin */
  GPIO_InitStruct.Pin = DL3_Pin;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  LL_PWR_EnableGPIOPullUp( LL_PWR_GPIO_B, DL3_Pin);
  //LL_PWR_EnableGPIOPullUp( LL_PWR_GPIO_A, GPIO_PIN_0);


  /* Check if the system was resumed from Deepstop mode */
    if (__HAL_PWR_GET_FLAG(PWR_FLAG_DEEPSTOPF) != RESET)
    {
      /* Clear Deepstop flag */
      __HAL_PWR_CLEAR_FLAG(PWR_FLAG_DEEPSTOPF);

      /* Check and Clear the Wakeup flag */
//      if (__HAL_PWR_GET_FLAG(PWR_FLAG_WUFB0) != RESET)
//      {
//        __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUFB0);
//      }
      /* Check and Clear the Wakeup flag */
	  if (__HAL_PWR_GET_FLAG(PWR_FLAG_WUFA0) != RESET)
	  {
		__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUFA0);
	  }

      //HAL_GPIO_WritePin(DL2_GPIO_Port, DL2_Pin, GPIO_PIN_SET);
	  HAL_GPIO_WritePin(DL3_GPIO_Port, DL3_Pin, GPIO_PIN_SET);
      HAL_Delay(3000);
      HAL_GPIO_WritePin(DL3_GPIO_Port, DL3_Pin, GPIO_PIN_RESET);
      /* Wait that user release the USER push-button */
      //NVIC_SystemReset();
    }


    for (uint16_t i=0; i<10; i++)
    {	//Lampeggi il led
    	HAL_GPIO_WritePin(DL3_GPIO_Port, DL3_Pin, GPIO_PIN_SET);
    	HAL_Delay(250);
    	HAL_GPIO_WritePin(DL3_GPIO_Port, DL3_Pin, GPIO_PIN_RESET);
    	HAL_Delay(250);
    }

    HAL_GPIO_WritePin(DL3_GPIO_Port, DL3_Pin, GPIO_PIN_RESET);

    //HAL_GPIO_WritePin(DL2_GPIO_Port, DL2_Pin, GPIO_PIN_SET);
    LL_PWR_EnableGPIOPullUp( LL_PWR_GPIO_A, PWR_WAKEUP_PIN0);	//LL_PWR_DisableGPIOPullUp( LL_PWR_GPIO_A, PWR_WAKEUP_PIN0);
    LL_PWR_EnableGPIOPullUp( LL_PWR_GPIO_B, PWR_WAKEUP_PIN10);	//LL_PWR_DisableGPIOPullUp(LL_PWR_GPIO_B, PWR_WAKEUP_PIN10); //
	/* Enable WakeUp Pin PWR_WAKEUP_PIN0 connected to  */
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PORTA, PWR_WAKEUP_PIN0, PWR_WUP_FALLEDG );
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PORTB, PWR_WAKEUP_PIN10, PWR_WUP_FALLEDG );	//PB10 = B_APRI_Pin
	/* Clear all related wakeup flags*/
	//__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF_ALL); // Pulisce tutti i flag di Wakeup
	//__HAL_PWR_CLEAR_FLAG(PWR_FLAG_DEEPSTOPF);
    //__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF_ALL);
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUFA0);
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUFB10);

    //MODIFY_REG_FIELD(PWR->DBGR, PWR_DBGR_DEEPSTOP2, 1);

	//sConfigDEEPSTOP.deepStopMode = PWR_DEEPSTOP_WITH_SLOW_CLOCK_ON;
	sConfigDEEPSTOP.deepStopMode = PWR_DEEPSTOP_WITH_SLOW_CLOCK_OFF;
	/* Enter the Deepstop mode */
	 HAL_PWR_ConfigDEEPSTOP(&sConfigDEEPSTOP);
	 HAL_PWR_EnterDEEPSTOPMode();

	 while (1)
	 {
		HAL_GPIO_WritePin(DL3_GPIO_Port, DL3_Pin, GPIO_PIN_SET);
		HAL_Delay(1000);
		HAL_GPIO_WritePin(DL3_GPIO_Port, DL3_Pin, GPIO_PIN_RESET);
		HAL_Delay(1000);
	 }


  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */

    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
//	}
  /* USER CODE END 3 */
}

 

Question:

Is there any known limitation or required sequence for STM32WL31 DeepStop wakeup from GPIO?

Are there differences vs STM32WL33?

11 REPLIES 11
sbelcatronic
Associate III

Thank you xy3dg12,

as reported this: https://community.st.com/t5/stm32-mcus-wireless/stm32wl31-fails-to-exit-deepstop-from-rtc-wakeup/m-p/857987#M27001

You suggestion is correct, writing the AppBase by this line:

*(uint32_t*)0x20000014 = 0x10040000;

I solved my problem. I experienced the problem with the original linker script, so I don’t agree that it’s an AppBase variable corruption. I believe this is a bug in the microcontroller, since it should not enter the bootloader when waking up from DeepStop.

Simone

   

Hi @sbelcatronic@xy3dg12 

After internally deep check with wireless team, it seems that STM32CubeMX generates incorrect linker file which places RAM_VR data structure in wrong place.

This issue will be fixed in the coming releases of STM32CubeMX.

So, as proper solution is either to wait the fix with STM32CubeMX, or as workaround you can use the corresponding linker file for STM32WL33.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen