Other Parts Discussed in Thread: MSP430F5342
Hi!
On MSP430F5342 I trying to setup UART 115200 comunication with BLE module.
With DCO 1MHz and proper UART configuration registers everything works fine.
If I set DCO to 5MHz there is problem because all received MSB bits are set to "1". Other received bites in received characters are fine.
Code for 5MHZ DCO configuration:
// DCO ~5MHZ
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_5; // Select DCO range 16MHz operation
UCSCTL2 = FLLD_0 + 20; // Set DCO Multiplier for 5MHz
// (N + 1) * FLLRef = Fdco
// (152 + 1) * 32768 = 5MHz
__bic_SR_register(SCG0); // re-enable the FLL control loop
// Worst-case settling time for the DCO when the DCO range bits have been
// changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
// UG for optimization.
// 32 x 32 x 5 MHz / 32,768 Hz = 156250 = MCLK cycles for DCO to settle
__delay_cycles(160000);
Code for setup UART with DCO 5MHz and 115200 baud speed:
UCA0CTL1 |= UCSWRST; // **Put state machine in reset** UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 2; //UCBRx = INT(N/16) UCA0BR1 = 0; UCA0MCTL = UCBRF3 + //UCBRFx = round([(N/16) – INT(N/16)] × 16) UCOS16; // Overseampling enable UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
Thanks for any suggestions.