Calculating The USCI UART Baud Rate Register Values

Başlatan SpeedyX, 06 Şubat 2014, 15:15:08

SpeedyX

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:


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:


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
UCBRSx = 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:


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

http://processors.wiki.ti.com/index.php/USCI_UART_Baud_Rate_Gen_Mode_Selection