cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L071 MCU LPUART use LSE to configure BaudRate 9600. Actual BaudRate is 8300 or 11000.Error islarge. LSE is 32.768kHz ,One cycle is 30.517 us。One cycle of BaudRate 9600 is 3.4 times of LSE。But LSE frequency division can only be an integral multiple。

Wjian.4
Associate II

So,LPUART can not use LSE to configure BaudRate 9600?

6 REPLIES 6
Peter BENSCH
ST Employee

The LPUART can be clocked from various sources, but you have to compromise on accuracy when choosing the LSE as the clock.

The closest standard baudrates with an error below 2.5% are:

  • 4800, actual 4681, error 2.48%
  • 2400, actual 2340, error 2.48%
  • 1200, actual 1213, error 1.14%

 [edit]See comments below[/edit]

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Good luck!

/Peter

In order 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.

So, is this a lie?

0693W000007Cil8QAC.png 

JW

Peter BENSCH
ST Employee

Oops - @Community member​ is right. The values in RM0377 are correct because the 32 kHz is multiplied by 256 and then divided by the value in BRR.

The question now is what value @Wjian.4​ uses for BRR when trying to reach 9600 bps and where did he get it from?

Regards

/Peter

In order 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.

Hi @Peter BENSCH​ ,

And did you try?

I don't think there's any multiplier (i.e. PLL) involved. IMO it *is* a lie, and attempting to Tx at 9600 will result in transmitting bits with duration alternating between 3 and 4 1/32768 periods so, that in the long term the bits duration averages to the required 3.4 periods. The Rx would sample similarly.

This has chance to work with a precise counterpart and no other sources of timing error (asymmetric skew e.g. using optocouplers or slew rate limiting transceivers with asymmetric receiver threshold, and similar); however, I see lots of chances to result in marginal or simply not working combinations, e.g. if you'd try to communicate using this scheme on both ends.

That assertion in RM wouldn't be a lie, would there be a clean description of the LPUART working and all the gotchas I've mentioned above. Plus an exhaustive set of related appnotes, and, of course, comprehensive set of clean code examples without the "libraries" gobbledygook.

I did not try either, though; but would be surprised to be wrong.

JW

Wjian.4
Associate II

I tried.The value of BBR is set to 0x0036a.When the baud rate is set to 4800,The value of BBR is set to 0x006d4. And  actual BaudRate is 4672,The error is less than 3%. 32768 divided by 7 is 4681.So,the error of 4800 is small.As shown in the figure below,this is the actual baud rate when set to 9600.The pulse width of each bit is 8.3kHz or 11kHz.

Although the value of BBR is set to 0x0036a,but the fractional part of BBR(6a) no longer works.The total reason is that 32.768kHz can't divide the frequency to the corresponding period.

0693W000007CmvqQAC.png

So,is my idea right? The LPUART can not use LSE to configure BaudRate 9600?The error values in RM0377 are Wrong?Can you provide the actual error value when  configure BaudRate 9600?

Regards