Other Parts Discussed in Thread: MSP430F4152
I am confused by what I am seeing going on with my project and I am hoping someone can clue me in.
I have an MSP430F4152 with the SMCLK set to 4 MHz (128 X ACLK[32768]) and want to drive the UART at 115200. Reading the manual indicates that I need to set the prescalar, UCA0BR0 = 36, and the fractional portion, UCBRS = 3. However, I can't get any of my devices to run at this setting, which, on its own, is not a big deal. But, I am finding that I have to "tune" UCA0BR0 for each and every device! Once I find a setting that doesn't spit out garbage, I can find a narrow range, say UCA0BR0 = 25 - 28, that works while being relatively insensitive to UCBRS for a single device! I load another device and I find that it wants UCA0BR0 to be within 31 to 34. This seems crazy to me. The 32768 crystals (Citizen CM315) that I have on the boards are rock solid. I've tried using the oversampling mode to set the baud rate, but I can't find any setup that works (following the directions in the UM produces garbage).
Here is the initialization routine (well...at least for one of the deivces) for the UART:
void uart_init(void)
{
UCA0CTL1 = UCSWRST; // put into reset
UCA0CTL0 = 0x00; // 8N1
UCA0CTL1 |= UCSSEL_2; // Use SMCLK
UCA0BR0 = 29; // 4MHz 115200
UCA0BR1 = 0; // 4MHz 115200
UCA0MCTL = UCBRS_4; // Modulation
P6SEL |= BIT5+BIT6; // P6.5,6 = USCI_A0 RXD/TXD
UCA0CTL1 &= ~UCSWRST; // take out of reset
//IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
}
I am sure it is something that I am doing or not doing. Any help is greatly appreciated.
Thanks in advance.