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.

MSP432P401R Baud rate problem

Hello,

I'm trying to make my MSP communicate at 9600 bauds.

This is the code I use :

              // Configure HF pins pins
        PJ->SEL0 |= BIT2 | BIT3;                // set 2-UART pin as secondary function
        // Configure UART
        EUSCI_A0->CTLW0 |= EUSCI_A_CTLW0_SWRST; // Put eUSCI in reset
        EUSCI_A0->CTLW0 = EUSCI_A_CTLW0_SWRST |
                CS_CTL0_DCORSEL_3 | // DCO 12
                EUSCI_A_CTLW0_SSEL__SMCLK;    

        // Baud Rate calculation
        // 12000000/(16*9600) = 78.125
        // Fractional portion = 0.125
        // User's Guide Table 21-4: UCBRSx = 0x10
        // UCBRFx = int ( (78.125-78)*16) = 2
        EUSCI_A0->BRW = 78;                     // 12000000/16/9600
        EUSCI_A0->MCTLW = (2 << EUSCI_A_MCTLW_BRF_OFS) |
                EUSCI_A_MCTLW_OS16;

        EUSCI_A0->CTLW0 &= ~EUSCI_A_CTLW0_SWRST; // Initialize eUSCI

I have several questions.

* First, in the datasheet it is indicated that the calculation must be done this way : N = Fbrclk/BR. However, in the example code it is done this way : N = Fbrclk/(16*BR).

Why?

** When I try this code, the length of one bit is 400µs instead of 100µs at 9600 baud. When I try to do as the datasheet indicates (N = Fbrclk/BR), the length of one bit is much more longer...

.

Thank you

**Attention** This is a public forum