cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate baud rate error with an external low-frequency oscillator

kein
Associate III

Hi everyone,

I am working on a power-saving application using the STM32G030 series IC, and I need to configure the UART to work at a baud rate of 9600 with an external low-frequency oscillator (32.768 kHz).

My goal is to ensure that the UART baud rate tolerance below 2.5%. Could you advise on how to calculate the baud rate error in this scenario?

Additionally, are there any other potential issues I should be aware of with this configuration?

Best regards.

1 ACCEPTED SOLUTION

Accepted Solutions

You can't use UART with baudrate divisor below 16 anyway. LPUART is capable of that, but with some caveats, and the baudrate error - more precisely and more importantly, bit duration - is of course consequence of clock chosen, as others said.

Why do you think you need that particular value of baudrate error? Is it going to be used as Rx or Tx?  What's the counterpart and what exactly is the link between them? 

JW

View solution in original post

6 REPLIES 6
Andrew Neil
Evangelist III

The USART baud rate register (USART_BRR) tells you the division factor that the baud rate generator applies to its input clock

AndrewNeil_0-1723197946713.png

Thus you can work out the actual baud rate and, thence, the error from your desired baud rate.

I follow the formula and got the closest actual baudrate is 9362Hz (2*32768/7, USARTDIV=7, OVER8=0)

The tolerence is too large and cannot be used.

is there any other solution like LPUART, or other IC can works in this case?

LCE
Principal

You have a general problem there.

Especially a "non-clocked" async interface like the UART needs some oversampling to work reliably, AND a half-way fitting clock rate.

So either use some higher clock rate, or - if low power is the most important feature - lower the baud rate.

You can't use UART with baudrate divisor below 16 anyway. LPUART is capable of that, but with some caveats, and the baudrate error - more precisely and more importantly, bit duration - is of course consequence of clock chosen, as others said.

Why do you think you need that particular value of baudrate error? Is it going to be used as Rx or Tx?  What's the counterpart and what exactly is the link between them? 

JW

Thanks for reply.

Initially, I just wanted to determine whether this configuration could achieve the goal. Now I understand that this is only possible with LPUART (but not available in my IC).

The connected device is a wireless module with 9600 baud, which uses both RX and TX. 

And the concern about baud rate errors because environment could be high and low temperatures, which can cause the oscillator to deviate and lead to communication failures.

Again, Thank you all for the help.

Crystal oscillators don't drift with temperature significantly for UART to fail just because of that reason.

However, I see that the nonexact bit duration may be a concern. Would you have LPUART available, I'd suggest to investigate, whether the counterpart can't be set to different (lower) baudrate. 

JW