I'm using a MSP430F5529 clocked at 1 MHz and want to use the UART at 9600 bauds. So far I did:
void UART_init(void) {
UCA0CTL1 |= UCSWRST; // Reset the UART's state machine
UCA0CTL0 |= UCMSB; // MSB first, 8n1 mode
UCA0CTL1 |= UCSSEL_2; // SMCLK
// 1 MHz/9600 baud = 104.666.
// Rounding down to 104 = 9615 bauds
UCA0BR0 = 104;
UCA0BR1 = 0;
}
But now I don't understand how to choose the value of the modulation register (UCA1MCTL
) so as to get as close to 9600 bauds as possible. The MSP430Fx5xx user's guide, at page 908, proposes to use UCBRS_1
, but I don't understand how this value is reached.
How do I calculate this register?
Best Answer
There are a number of calculators to simplify the process, such as this one; simple msp430 baud rate bit calculator
If you want more detailed information on how this is calculated I recomemend this great tutorial by Gustavo Litovsky Specifically section 12.3.5 on PDF page 101
Hope this helps.