1
\$\begingroup\$

I'm using a STM32L0 MCU for my project. The MCU has a Low-power Timer (LPTIM) for waking the MCU up from Stop-Mode, and a Low-power UART (LPUART) for both waking up the MCU from stop mode and receive/transmit data.

My problem is: - When I let the MCU staying in running mode, LPUART working fine at baudrate over 256000. - When I set MCU to go to Stop-mode, then when the MCU receives something from LPUART-Rx, it's woken up and keep reading the received sequence data. For this set up, when UART baudrate is lower than 56000 it works fine. However when the baudrate is higher than this (e.g at 115200), LPUART read the wrong data. I'm aware that in this set-up, the first transmitted byte will be lost but the others should be read correctly.

I tried with several different transmitted data with different lengths, however the received data is always wrong. (work fine when baudrate is 56000 though).

\$\endgroup\$
  • 1
    \$\begingroup\$ Isn't there any limitations about the BAUD rate of the low-power UART? Could you link a reference manual? \$\endgroup\$ – Bence Kaulics Sep 28 '16 at 10:34
  • \$\begingroup\$ Hi, yes there is a limit in Low-power UART but only when using LSI/LSE. In my case, when LPUART receives something, DSP will be woken up and using HSI clock. And also when staying in Run-mode, LPUART has no problem with high baudrate (at least up to 256000 as I tested). Here the reference manual: st.com/content/ccc/resource/technical/document/reference_manual/… \$\endgroup\$ – bienle Sep 28 '16 at 13:50
  • \$\begingroup\$ What is your clock configuration regarding the LPUART? \$\endgroup\$ – Bence Kaulics Sep 28 '16 at 16:17
4
\$\begingroup\$

Wakeup from Stop mode using LPUART

The LPUART is able to wake up the MCU from Stop modewhen the UESM bit is set and the LPUART clock is set to HSI or LSE (refer to the Reset and clock control (RCC) section.

  • LPUART source clock is HSI
    If during stop mode the HSI clock is switched OFF, when a falling edge on the LPUART receive line is detected, the LPUART interface requests the HSI clock to be switched ON. The HSI clock is then used for the frame reception.

    • If the wakeup event is verified, the MCU wakes up from low-power mode and data reception goes on normally.
    • If the wakeup event is not verified, the HSI clock is switched OFF again, the MCU is not waken up and stays in low-power mode and the clock request is released.

When the LPUART starts to receive data, the clocks won't be active immediately. HSI16 (high speed internal 16 MHz RC oscillator) typically takes 3.7 μs to start.*

You can eliminate the HSI16 startup time by leaving it running during stop mode, if you really need to do so. Once the HSI16 is available, the LPUART itself has to activate, which takes up to 12 μs* as well:

*The reference manual doesn't mention any startup times as they are specific to each individual part. You can find the actual values in the datasheet, the value here is for the STM32L051x6/8 and listed here only for illustrative purposes.

At 56 kbaud, the transmission period of one bit is 17.86 μs, which is barely long enough (still probably out of spec) for the LPUART to wake up before the next bit arrives and everything goes out of sync. This is why you can't increase the baud rate.

See "Determining the maximum LPUART baudrate allowing to wakeup correctly from Stop mode when the LPUART clock source is the HSI clock" (page 734, reference manual)

\$\endgroup\$
  • \$\begingroup\$ I think you should copy the example calulation in the ideal case from the manual. \$\endgroup\$ – Bence Kaulics Sep 28 '16 at 18:25
  • \$\begingroup\$ @BenceKaulics OP has not disclosed which specific chip is being used, so I can't do the actual calculation. I did refer to the relevant part of the reference manual, if that isn't enough feel free to improve my answer. \$\endgroup\$ – jms Sep 28 '16 at 18:33
  • \$\begingroup\$ Just as an exemplification. \$\endgroup\$ – Bence Kaulics Sep 28 '16 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.