USCI UART Baud Rate Gen Mode Selection

From Texas Instruments Wiki
Jump to: navigation, search

Calculating The USCI UART Baud Rate Register Values

The formulas for calculating USCI UART Baud Rate Register Values are basically available in the Family User's Guide document.

For calculating all the formula, it requires the division factor N:

N = fBRCLK/Baudrate

Where fBRCLK is basically the input clock frequency of the USCI module as shown in the USCI block diagram as follows:

Usci brclk.png

If N >= 16, it is possible to enable the oversampling mode (setting UCOS16=1).


Low Frequency Baud-Rate Mode Setting (UCOS16=0)

In Low Frequency Baud-Rate Mode Setting, the baud rate prescaler register UCBRx and the fractional portion modulator UCBRSx can be calculated as follows:

UCBRx = INT(N) -> integer part of N

UCBRSx = round((N - INT(N))*8) -> integer rounding of fractional part of N times 8

Comparing it to the Baud Rate Setting Register Table provided in the User Guide document tidoc:slau208m Table 34-4. "Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 0"-

  • For fBRCLK=1MHz, BR=9600: N=1000000/9600 = 104,16666667
    • UCBRx = INT(N) = 104
    • UCBRSx = round (0,16666667 * 8) = round (1,33333333) = 1
  • For fBRCLK=1MHz, BR=19200: N=1000000/19200 = 51,020408163265306122448979591837
    • UCBRx = INT(N) = 51
    • UCBRSx = round (0,020408163265306122448979591837 * 8) = round (0,16326530612244897959183673469388) = 0
  • For fBRCLK=1MHz, BR=38400: N=1000000/38400 = 26,041666666666666666666666666667
    • UCBRx = INT(N) = 26
    • UCBRSx = round (0,041666666666666666666666666667 * 8) = round (0,33333333333333333333333333333333) = 0
  • For fBRCLK=1MHz, BR=57600: N=1000000/57600 = 17,361111111111111111111111111111
    • UCBRx = INT(N) = 17
    • UCBRSx = round (0,361111111111111111111111111111 * 8) = round (2,8888888888888888888888888888889) = 3
  • For fBRCLK=1MHz, BR=115200: N=1000000/115200 = 8,6805555555555555555555555555556
    • UCBRx = INT(N) = 8
    • UCBRSx = round (0,6805555555555555555555555555556 * 8) = round (5,4444444444444444444444444444444) = 6


Oversampling Baud-Rate Mode Setting (UCOS16=1)

In Oversampling Mode Setting, the baud rate prescaler register UCBRx and the first stange modulator register UCBRFx can be calculated as follows:

UCBRx = INT(N/16) -> integer part of N divided by 16

UCBRFx = round(((N/16) - INT(N/16))*16) -> integer rounding of fractional part of N divided by 16 times 16

Comparing it to the Baud Rate Setting Register Table provided in the User Guide document tidoc:slau208m Table 34-5. "Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 1".

  • For fBRCLK=4MHz, BR=9600: N/16=4000000/9600/16 = 26,041666666666666666666666666667
    • UCBRx = INT(N/16) = 26
    • UCBRFx = round (0,041666666666666666666666666667 * 16) = round (0,66666666666666666666666666666667) = 1
  • For fBRCLK=4MHz, BR=19200: N/16=4000000/19200/16 = 13,020833333333333333333333333333
    • UCBRx = INT(N/16) = 13
    • UCBRFx = round (0,020833333333333333333333333333 * 16) = round (0,33333333333333333333333333333333) = 0
  • For fBRCLK=4MHz, BR=38400: N/16=4000000/38400/16 = 6,5104166666666666666666666666667
    • UCBRx = INT(N/16) = 6
    • UCBRFx = round (0,5104166666666666666666666666667 * 16) = round (8,1666666666666666666666666666667) = 8


USCI UART Calculator

Clock Speed: Baud Rate: Calculate USCI Dividers


USCI Automatic Header File Calculator

It is possible to calculate the USCI setting automatically in the header file using C preprocessor as shown in this link.

FAQ

Can I use the Low-Frequency Baud-Rate mode at high frequencies, or must I use the Oversampling Mode?

The UCOS16 bit for the F5xx devices determines which baud rate mode is used. The MSP430F5xx Family User's Guide tidoc:slau208m (chapter 34.3.10 "Setting a Baud Rate") states: if N is greater than 16 then the oversampling mode can be used, but it doesn’t say that is must be used.

The Low-Frequency Baud-Rate Mode can be used for the full scale of baud rates and input clock frequencies per device datasheet, while the Oversampling Baud-Rate Mode can only be used with higher clock inputs (N > 16).

The Baud rate table (Table 34-4. "Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 0" and Table 34-5. "Commonly Used Baud Rates, Settings, and Errors, UCOS16 = 1")intuitively reflects this as well.