cancel
Showing results for 
Search instead for 
Did you mean: 

Stm32U545 not waking up from stop 2 using wakeup pin and LPBAM

M_R_Kersten
Visitor

Heyy,

I'm using an STM32u545 (on a Nucleo board), and I'm trying to wake up my MCU from stop 2 mode using wake-up pin 2. Wake-up pin 2 is connected to LPTIM3 (via a jumper wire), and LPTIM3 works.

Besides trying to wake up the CPU. An LPBAM application is collecting data using the ADC4 and LPDMA with LPTIM1. Also, it does work. But now I don't know how to wake the CPU using LPTIM3. Did I miss something, or is this not the way to go/ is there an easier way to do this?

The program should:

- read data on a specific frequency

- wake up every two seconds to write the data to an SD card (eventually)

Thanks in advance :)

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_LPDMA1_Init();
  MX_ICACHE_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
  /* LPBAM TempSens application init */
  MX_LPBAM_DMA_ADC_Init();
  /* LPBAM TempSens application MultiThres scenario init */
  MX_LPBAM_DMA_ADC_DMA_ADC_Init();
  /* LPBAM TempSens application MultiThres scenario build */
  MX_LPBAM_DMA_ADC_DMA_ADC_Build();
  /* LPBAM TempSens application MultiThres scenario link */
  MX_LPBAM_DMA_ADC_DMA_ADC_Link(&handle_LPDMA1_Channel1);
  /* LPBAM TempSens application MultiThres scenario start */
  MX_LPBAM_DMA_ADC_DMA_ADC_Start(&handle_LPDMA1_Channel1);

  /* Entering STOP2 mode */
  Enter_Stop2_Mode();

  /* LPBAM TempSens application MultiThres scenario stop */
  MX_LPBAM_DMA_ADC_DMA_ADC_Stop(&handle_LPDMA1_Channel1);
  /* LPBAM TempSens application MultiThres scenario unlink */
  MX_LPBAM_DMA_ADC_DMA_ADC_UnLink(&handle_LPDMA1_Channel1);
  /* LPBAM TempSens application MultiThres scenario de-init */
  MX_LPBAM_DMA_ADC_DMA_ADC_DeInit();

  /* USER CODE END 2 */
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1) {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
    HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_13);
    HAL_Delay(1000);
  }
  /* USER CODE END 3 */
}
static void Enter_Stop2_Mode(void) {
  /* Clear stop flag */
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_STOPF);

  /* Check that stop flag is cleared */
  if (__HAL_PWR_GET_FLAG(PWR_FLAG_STOPF) != 0U) {
    Error_Handler();
  }

  /* Clear The Wakeup Flag */
  __HAL_PWR_CLEAR_FLAG(PWR_WAKEUP_FLAG2);
  /* Enable The WKUP1 Pin */
  HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);

  /* Enter the system to STOP2 mode */
  __HAL_RCC_PWR_CLK_ENABLE();
  HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);

  /* Check that the system was resumed from stop 2 */
  if (__HAL_PWR_GET_FLAG(PWR_FLAG_STOPF) == 0U) {
    Error_Handler();
  }
}

 [Moderation edit: beautified and inserted as C Code sample using </>)]

0 REPLIES 0