Skip to main content
MMust.5
Senior
July 1, 2022
Question

How to check UART baud rate without using BRR register?

  • July 1, 2022
  • 10 replies
  • 2465 views

Maybe in some register the baud rate is saved?

This topic has been closed for replies.

10 replies

Tesla DeLorean
Guru
July 1, 2022

The hardware doesn't need it, it uses clock ratios.

​

Might find in a variable or structure held in Memory..

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MMust.5
MMust.5Author
Senior
July 1, 2022

In what structure?

Where can I find the current UART baud rate in memory?

Andrew Neil
Super User
July 1, 2022

It's your software that configures the UART - including setting the baud rate - so your software must know what baud rate it set!

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Michal Dudka
Lead
July 1, 2022

It is little bit strange request (your program writes some value into BRR, you should be able to find that value in your source code). But, simple, connect oscilloscope to UART TX signal, send some unambiguous character (like 0x00, or 0xFF etc.) and measure bit time duration from oscilloscope trace.

Andrew Neil
Super User
July 1, 2022

@Michal Dudka​ "It is little bit strange request (your program writes some value into BRR, you should be able to find that value in your source code)"

Absolutely!

"send some unambiguous character"

Best choice would be uppercase 'U' - that should give a square wave with 1 start & 1 stop bit ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Tesla DeLorean
Guru
July 1, 2022

You do seem to struggle with very basic methods here.

https://community.st.com/s/question/0D53W00001db87nSAA/what-is-written-to-the-usartbrr-register

The machine uses relative clock ratios to relate one clockable source to another.

The machine doesn't keep a record of your "baud rate", it only knows that it is some fraction of the bus clock rate. ie Baud Rate = APBxCLK / USARTx->BRR

Will be in structure hUart,

ie hUart->Init.BaudRate where UART_HandleTypeDef *hUart;

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
July 1, 2022

If the RX pin is connected to a TIM Channel, you could measure the pulse widths, the shortest being One Bit Time, the others presumably being some higher integer multiple of that.

For example 9600 baud being around 0.1042666 ms

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..