cancel
Showing results for 
Search instead for 
Did you mean: 

Baudrate for USART

roderick1983
Associate II
Posted on December 28, 2009 at 20:34

Baudrate for USART

11 REPLIES 11
roderick1983
Associate II
Posted on May 17, 2011 at 13:35

Could some body answers my question:I set the baudrate of STM32's USART ,should i chose special crystal as AVR or MCS-51? Example,On MCS-51 or AVR,we useing crystal of 11.0592MHz or 18.432MHz,we can get no error baudrate from 110bps to 115200bps.

Chinese:

请问一下用了STM32的朋�?�,对它的串�?�设置波特率会�?会�?�?AVR或51一样选用特定的晶振�?�使波特率没有误差?比如51或AVR在使用11.0592或18.432等晶振时波特率从110到115200都没有误差。 :-[

picguy
Associate II
Posted on May 17, 2011 at 13:35

Read The Fine Manual - table 176 on page 679 shows exact baud rates and baud rage generator values for 72 MHz operation. Examples cover 2400 to 115200 baud and beyond. At 36 MHz only 115200 baud is off by 0.15%. This is well within the tolerance range for USART communication.

These operational frequencies are easily obtained using a 8 MHz crystal. Such parts may cost less. Future availability is more likely as well.

RM0008 is only slightly over 1000 pages. A month of banging your head and asking questions will save you few days reading all of it.

akaiser9
Associate II
Posted on May 17, 2011 at 13:35

Having a fractional baud rate generator makes baud rate crystals unnecessary. Otherwise it would be impossible to use both CAN/USB and UART with their typical rates.

roderick1983
Associate II
Posted on May 17, 2011 at 13:35

Thanks for you.

picguy,I have two datasheets with STM32F103XB and 103XD,but they has 123 pages,I can not find 679 pages!And I can't find the fine manual on the ST's web,can you tell me the web address for download?Thanks a lot! 😉

roderick1983
Associate II
Posted on May 17, 2011 at 13:35

prx:

Your mean is that the STM32 has a Independent Baud Rate Generator?

picguy
Associate II
Posted on May 17, 2011 at 13:35

Find “Search Keyword�? box on st.com main page. Type RM0008. Press enter. Right click on first found item and “save link target as...�?. QED - Latin for Quite Easily Done.

st3
Associate II
Posted on May 17, 2011 at 13:35

Quote:

I can't find the fine manual on the ST's web

Really??

They are all here:

http://www.st.com/mcu/familiesdocs-110.html

akaiser9
Associate II
Posted on May 17, 2011 at 13:35

Quote:

Your mean is that the STM32 has a Independent Baud Rate Generator?

Never heard of this term. The baud rate divider is not an integer divider, but has a 4 bit fractional part. A bit simplified it means that you get the results of a regular integer divider fed with 16 times the system/bus clock. Which means you a get sufficiently precise baud rate derived from any system clock rate unless it's exceptionally low.

picguy
Associate II
Posted on May 17, 2011 at 13:35

Forget the fraction part. Here’s how: all STM32 USART sections use a 16x the baud rate clock. Therefore load the 16-bit clock divisor with x/(16*baudRate) where x = the input frequency. In many cases the input frequency is 72 MHz for USART1 and 36 MHz for the others. Thus for USART1 at 4.5 Mbaud the 16-bit clock divisor is 1.

My head would spin off if I had to think of this as 0.0625

The reason for exact or quite close enough is the high (by historical standards) input frequency and the large range of divisor possibilities. For USART1 for 9600 baud I would load USART_BRG with 72000000/(16*9600) and let the assembler or compiler do the arithmetic.