cancel
Showing results for 
Search instead for 
Did you mean: 

LPUART running with LSI clock can wakeup from STOP2 mode?

npatil15
Associate III

Hello,

Need information about, does LPUART can wakeup? if the clock source is LSI (32Khz)?

Because I have tried multiple examples to wakeup but it only works in debug mode but not in release mode.

I have also work on optimization level, currently optimization is None for both debug and release.

Thanks,

Nitin

6 REPLIES 6
KnarfB
Super User
npatil15
Associate III

As per doc, page no 30, LPUART wakeup support only in STOP1 mode not in STOP2 mode. Is that correct ?

Also confuse it say clock source LSI/LSE support, does that mean it does not support HSI to wakeup ?

npatil15_0-1762870960209.png

Edited: Yes it is also shown in the STOP2 mode, but again does it not support to wakeup at HSI clock ?

Using Custom board, HAL library, bare metal, STM32U0 series controller. Connected with 12 volt power supply and ST-Link Debugger for code dump.

 

npatil15
Associate III

For more information using, HAL_UARTEx_ReceiveToIdle_IT()  for receiving data and transmitting using  HAL_UART_Transmit_IT() , So also need to understand does the ReceiveToIdeal support for wakeup event?

Actually I didnt get example code using ReceiveToIdeal() interrupt event.

According to the reference manual STM32U0 series advanced Arm<Sup>®</Sup>-based 32-bit MCUs - Reference manual Figure 11. Clock tree, LSI is not an option for LPUART.

KnarfB

npatil15
Associate III

Ohh yes, I was looking at wrong peripheral, I was using HSI.

I'm not sure why the it does not wakeup when rx has some data. Actually I have implement LPTIMER to wakeup at every 2 seconds, so that work perfectly but if RX has data then it dosnt wakeup.

So when lptimer wakeup then it found that RX buffer is filled then it process the RX frame and send the response, then again it wait for lptimer to wakeup again.

During Init()

    LPUART1_EXTI_ENABLE_IT()   (EXTI->IMR1 |= EXTI_IMR1_IM28)
    __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);
    __HAL_RCC_HSI_ENABLE();

 

Then if no RX or lptimer then go to stop2 mode

  //Preparation for next receive data 
   RS485_RX_ENABLE();//Its macro to receive RX data on line.
  __HAL_UART_FLUSH_DRREGISTER(&hlpuart1);
  HAL_UART_AbortReceive(&hlpuart1)
  HAL_UARTEx_ReceiveToIdle_IT(&hlpuart1, &gRxBuf[0], UART_RX_BUF_SIZE);

  //Below code is to go stop2 mode
  __HAL_UART_CLEAR_FLAG(&hlpuart1, UART_CLEAR_PEF | UART_CLEAR_NEF | UART_CLEAR_OREF);
  uint32_t dummy = hlpuart1.Instance->RDR; // flush RDR
  (void)dummy;  

   WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_STARTBIT;
  if (HAL_UARTEx_StopModeWakeUpSourceConfig(&hlpuart1, WakeUpSelection) != HAL_OK)
  {
    Error_Handler();
  }
  while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_BUSY) == SET);

  /* make sure that LPUART is ready to receive
   * (test carried out again later in HAL_UARTEx_StopModeWakeUpSourceConfig) */
  while (__HAL_UART_GET_FLAG(&hlpuart1, USART_ISR_REACK) == RESET);

  /* Enable the LPUART Wake UP from STOP mode Interrupt */
  __HAL_UART_DISABLE_IT(&hlpuart1, UART_IT_WUF);
  __HAL_UART_ENABLE_IT(&hlpuart1, UART_IT_WUF);

  /* enter STOP mode */
  HAL_UARTEx_EnableStopMode(&hlpuart1);
  HAL_SuspendTick();
  HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
  HAL_ResumeTick();
  Reset_SystemClock();
  HAL_UARTEx_DisableStopMode(&hlpuart1);

npatil15_0-1762874451863.png

npatil15_1-1762874485616.png

 

Help me to find what I'm missing here?

Thanks,

Nitin

Hello @npatil15 

According to the reference manual, LPUART wake-up from Stop mode is only supported when either HSI16 or LSE is used as the clock source.

Saket_Om_0-1762874339539.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om