cancel
Showing results for 
Search instead for 
Did you mean: 

wake up from standby mode U545REQ

dlagyals
Visitor

Hi,

I set the button on the board to WAKE_UP2 to wake up from standby mode, but it doesn't work.

Also, waking up through the RTC interrupt doesn't work either.

The LSE source is an external crystal.

This is my code:

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 Power */
SystemPower_Config();

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

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ICACHE_Init();
MX_USART1_UART_Init();
MX_RTC_Init();

/* USER CODE BEGIN 2 */
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SBF) !=RESET)
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SBF);
char *str ="Wakeup form the STANDBY MODE\r\n\n";
HAL_UART_Transmit(&huart1, (uint8_t*)str, strlen(str), 10);

for(int i=0; i<20; i++)
{
  HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
  HAL_Delay(200);
}

HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
}
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SBF);
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc,RTC_FLAG_WUTF);

char *str ="Enter the STANDBY MODE\r\n\n";
HAL_UART_Transmit(&huart1, (uint8_t*)str, strlen(str), 10);

for(int i=0; i<5; i++)
{
  HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
  HAL_Delay(1000);
}

HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);

if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x2710, RTC_WAKEUPCLOCK_RTCCLK_DIV16, 0) != HAL_OK)
{
  Error_Handler();
}

char *str2 ="STANDBY MODE is ON\r\n\n";
HAL_UART_Transmit(&huart1, (uint8_t*)str2, strlen(str2), 10);

HAL_PWR_EnterSTANDBYMode();

/* USER CODE END 2 */
0 REPLIES 0