cancel
Showing results for 
Search instead for 
Did you mean: 

How to check UART baud rate without using BRR register?

MMust.5
Senior II

Maybe in some register the baud rate is saved?

10 REPLIES 10

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
Up vote any posts that you find helpful, it shows what's working..

In what structure?

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

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.

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

@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 ...

I understand that my code says what should be the data transfer rate.

But if I don't want to analyze a very large code, but just want to see the UART baud rate.

>It's your software that configures the UART

software?? You probably meant code.

I am not writing about a program on a computer that receives data from a UART.

The program on the computer is simply tuned to the data transfer frequency indicated in the code, the data transfer rate does not depend on the program.

@Community member​ - No, I meant your software (aka "firmware" or "code") that's running on the STM32.

"I don't want to analyze a very large code"

Are you talking about some 3rd-party code, then?

As @Michal Dudka​ said, it's a strange request - so hard to know what you're actually trying to achieve.

"just want to see the UART baud rate"

Then, as @Michal Dudka​ said, the easiest way is to just measure it externally.

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
Up vote any posts that you find helpful, it shows what's working..