This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5659: UART Supported Baud Rates

Part Number: MSP430F5659

I am currently using Code Composer with my embedded MSP430F5659 for firmware development. My application requires to reliably communicate with a host over its UART (USCI A2) interface at 115200 baud rate.

At this baud rate, the UART drops characters and does not keep up with the host. I need to know what is the recommended reliable baud rate to be used with USCI A2 UART and what are the parameters and the relevant control registers to set it up for that baud rate at 8 data bits, no parity, 1 stop bit.

  • What are your clock frequencies?

  • Thanks for the quick response. The clock rate is  1.048 MHz.

  • Use calculator for parameters. F5xx at full speed (MCLK 24 MHz) UART can go up to 6 Mbps. And 115200 should be no problem with 1 MHz MCLK.

    1122.MSP430UartCalc.zip

  • You also have to determine whether it is the UART dropping characters or your software. at 1 MHz, you don't have much time to respond to characters.

  • It is possible. For that reason, I would like to program the UARTS for slower baud rate but I am not sure what parameters and registers should be set up with what values for 9600 and 9200 baud rates. 

    The following code woks for 11520, 5760, 38400 baud rates provided setting correct value for UCA2BRW. However, it does not work for 9600 and 19200 baud rates:

    void SerialUART::SetupUART(void)
    {
    infoAvail = 0;
    txOverflow = 0;
    _DINT();
    UCA2CTL1 |= UCSWRST; // Put USCI_A2 in reset state
    // NOTE: For the msp430f5x family, the CTL register should be accessed as two bytes.
    UCA2CTL0 = 0; // UART mode (8,n,1,lsb)
    UCA2CTL1 = UCSSEL__SMCLK + UCRXEIE + UCBRKIE + UCSWRST;
    UCA2BRW = 9; // Baudrate = 115200 //for 1.048 MHz
    //UCA2BRW = 18; // Baudrate = 57600 //for 1.048 MHz
    //UCA2BRW = 27; // Baudrate = 38400 //for 1.048 MHz
    //UCA2BRW = 3; // Baudrate = 19200 //for 1.048 MHz
    //UCA2BRW = 6; // Baudrate = 9600 //for 1.048 MHz

    UCA2MCTL = 0x0002; // this is for 115200, 57600, 38400

    UCA2CTL1 &= ~(UCSWRST); // Put USCI_A2 in operational state
    UCA2IE |= UCTXIE + UCRXIE; // enable TX- & RX- interrupts
    _EINT();
    }

  • The user guide has a long section on setting baud rates including recommended settings. (Table 39-5) You seem to have left out the code to set the modulator stage and are confused on the use of the UCOS16 bit.

    Also, TXIFG is set during device reset so you will get an immediate transmit interrupt at _EINT().

  • Thanks for your reply. Unfortunately, the registers shown in table 39-5 does not match the definitions from msp430f5659.h provided by Code Composer.

    The following registers are available from the header file and I need to know which one of these registers should be set to what values to support 9600 and 19200 baud rates:

    /************************************************************
    * USCI A2
    ************************************************************/
    #define __MSP430_HAS_USCI_A2__ /* Definition to show that Module is available */
    #define __MSP430_BASEADDRESS_USCI_A2__ 0x0640
    #define USCI_A2_BASE __MSP430_BASEADDRESS_USCI_A2__

    SFR_16BIT(UCA2CTLW0); /* USCI A2 Control Word Register 0 */
    SFR_8BIT(UCA2CTLW0_L); /* USCI A2 Control Word Register 0 */
    SFR_8BIT(UCA2CTLW0_H); /* USCI A2 Control Word Register 0 */
    #define UCA2A@CTL1 UCA2CTLW0_L /* USCI A2 Control Register 1 */
    #define UCA2CTL0 UCA2CTLW0_H /* USCI A2 Control Register 0 */
    SFR_16BIT(UCA2BRW); /* USCI A2 Baud Word Rate 0 */
    SFR_8BIT(UCA2BRW_L); /* USCI A2 Baud Word Rate 0 */
    SFR_8BIT(UCA2BRW_H); /* USCI A2 Baud Word Rate 0 */
    #define UCA2BR0 UCA2BRW_L /* USCI A2 Baud Rate 0 */
    #define UCA2BR1 UCA2BRW_H /* USCI A2 Baud Rate 1 */
    SFR_8BIT(UCA2MCTL); /* USCI A2 Modulation Control */
    SFR_8BIT(UCA2STAT); /* USCI A2 Status Register */
    SFR_8BIT(UCA2RXBUF); /* USCI A2 Receive Buffer */
    SFR_8BIT(UCA2TXBUF); /* USCI A2 Transmit Buffer */
    SFR_8BIT(UCA2ABCTL); /* USCI A2 LIN Control */
    SFR_16BIT(UCA2IRCTL); /* USCI A2 IrDA Transmit Control */
    SFR_8BIT(UCA2IRCTL_L); /* USCI A2 IrDA Transmit Control */
    SFR_8BIT(UCA2IRCTL_H); /* USCI A2 IrDA Transmit Control */
    #define UCA2IRTCTL UCA2IRCTL_L /* USCI A2 IrDA Transmit Control */
    #define UCA2IRRCTL UCA2IRCTL_H /* USCI A2 IrDA Receive Control */
    SFR_16BIT(UCA2ICTL); /* USCI A2 Interrupt Enable Register */
    SFR_8BIT(UCA2ICTL_L); /* USCI A2 Interrupt Enable Register */
    SFR_8BIT(UCA2ICTL_H); /* USCI A2 Interrupt Enable Register */
    #define UCA2IE UCA2ICTL_L /* USCI A2 Interrupt Enable Register */
    #define UCA2IFG UCA2ICTL_H /* USCI A2 Interrupt Flags Register */
    SFR_16BIT(UCA2IV); /* USCI A2 Interrupt Vector Register */

    The code sample I showed before works for 115200, 57600, and 38400 provided correct values used with  UCA2BRW. However, it does not work for 19200 and 9600. 

  • The fields in Table 39-5 are not registers but fields within registers. Look at the register definitions in the user guide. Scan down the header to where it defines values for the MCTL fields.

    Of course it doesn't work. You didn't set the modulation values and used BRW values for the lower rates that requires UCOS16 be set. Since that is in the lsb, writing 2 to that register doesn't cut it.

  • I see it now and I can also see that the right values are for the frequency 1.048 MHz are shown in table 36.4. Thank you so much for your help.

  • Thanks for the confirmation. Using your UART Calculator worked perfectly and I could use the code generated by the calculator to make it work for me at  lower baud rates. Thanks for your help again.

**Attention** This is a public forum