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.

CCS/MSP432P401R: MSP432P401R UART

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Good day,

I am making a project which uses UART. I want to use EUSCI_A2 on pins 3.2 and 3.3 for UART as I cannot access the pins on top for EUSCI_A0 because I am using a boosterpack that covers those pins. The problem is that I am trying to send data through UART to another MSP432, but it does not receive anything even if the TXBUF shows that data is being sent. I tried echoing the data back to the receiver buffer and when I do that the RXBUF is receiving the correct data. I have tried everything, but the receiver does not get any data. If you could help me I will be greatly thankful.

Thank you,

Luis Valerio

  • If local loopback is succeeding, but sending to another unit is failing, the first guess is that your bit-rate isn't right. (For local loopback, the bit-rate is always "correct".)

    The usual suspects then are (1) the clock you're using (SMCLK?) isn't what you think it is, or (b) your divider isn't right.

    If you show us your initialization code, someone might be able to see what the trouble is.
  • int main(void)
    {
        // Hold the watchdog
    
        volatile uint32_t i;
    
        WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD;
    
    
        P1->DIR = ~(uint8_t) BIT1;
        P1->DIR |= BIT0 ;
        //P1->OUT &= ~BIT0 ;
        P1->OUT |= 0 ;
        P1->OUT = BIT1;
        //P1->REN = BIT1;                         // Enable pull-up resistor (P1.1 output high)
        P3->SEL0 |= BIT2 | BIT3;
        P3->SEL1 = 0;
        //P1->IES = BIT1;                         // Interrupt on high-to-low transition
        //P1->IFG = 0;                            // Clear all P1 interrupt flags
        //P1->IE = BIT1;                          // Enable interrupt for P1.1
    
        EUSCI_A2->CTLW0 |= EUSCI_A_CTLW0_SWRST; // Put eUSCI in reset
        EUSCI_A2->CTLW0 = EUSCI_A_CTLW0_SWRST | // Remain eUSCI in reset
                EUSCI_B_CTLW0_SSEL__SMCLK;      // Configure eUSCI clock source for SMCLK
        // Baud Rate calculation
        EUSCI_A2->BRW = 1;                      // Using baud rate calculator
        EUSCI_A2->MCTLW = (10 << EUSCI_A_MCTLW_BRF_OFS) |
                EUSCI_A_MCTLW_OS16;
        EUSCI_A2->CTLW0 &= ~EUSCI_A_CTLW0_SWRST;// Initialize eUSCI
        EUSCI_A2->IE |= EUSCI_A_IE_RXIE;        // Enable USCI_A0 RX interrupt
    
        // Enable Port 1 interrupt on the NVIC
        //NVIC->ISER[1] = 1 << ((PORT1_IRQn) & 31);
        NVIC->ISER[0] = 1 << ((EUSCIA2_IRQn) & 31);
    
        // Configure Port J
        PJ->DIR |= (BIT0| BIT1 | BIT2 | BIT3);
        PJ->OUT &= ~(BIT0 | BIT1 | BIT2 | BIT3);
    
        // Enable PCM rude mode, which allows to device to enter LPM3 without waiting for peripherals
        //PCM->CTL1 = PCM_CTL0_KEY_VAL | PCM_CTL1_FORCE_LPM_ENTRY;
    
        // Enable global interrupt
        __enable_irq();
    
        // Setting the sleep deep bit
        //SCB->SCR |= (SCB_SCR_SLEEPDEEP_Msk);
    
        SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;   // Wake up on exit from ISR
    
        // Do not wake up on exit from ISR
        //SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
    
        // Ensures SLEEPONEXIT takes effect immediately
        __DSB();
    
        // Go to LPM4
        __sleep();
        while(1)
        {
        }
        }
    

  • int main(void)
    {
        volatile uint32_t i;
    
        WDT_A->CTL = WDT_A_CTL_PW |             // Stop watchdog timer
                WDT_A_CTL_HOLD;
    
        P2->DIR |= BIT2;
        P2->OUT &= ~BIT2;                       // P1.0 outout low
    
        // Configure UART pins
        P3->SEL0 |= BIT2 | BIT3;                // set 2-UART pin as second function
    
        // Configure UART
        EUSCI_A2->CTLW0 |= EUSCI_A_CTLW0_SWRST; // Put eUSCI in reset
        EUSCI_A2->CTLW0 = EUSCI_A_CTLW0_SWRST | // Remain eUSCI in reset
                EUSCI_B_CTLW0_SSEL__SMCLK;      // Configure eUSCI clock source for SMCLK
        // Baud Rate calculation
        EUSCI_A2->BRW = 1;                      // Using baud rate calculator
        EUSCI_A2->MCTLW = (10 << EUSCI_A_MCTLW_BRF_OFS) |
                EUSCI_A_MCTLW_OS16;
        EUSCI_A2->CTLW0 &= ~EUSCI_A_CTLW0_SWRST;// Initialize eUSCI
        EUSCI_A2->IE |= EUSCI_A_IE_RXIE;        // Enable USCI_A0 RX interrupt
    
        SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;   // Wake up on exit from ISR
    
        // Enable global interrupt
        __enable_irq();
    
        // Enable eUSCIA0 interrupt in NVIC module
        NVIC->ISER[0] = 1 << ((EUSCIA2_IRQn) & 31);
    
        while (1)
        {
    //        // Arbitrary delay between each transmit to observe the
    //        // characters being transmitted through a scope
    //        for (i = 10; i > 0; i--);
    //
    //        while(!(EUSCI_A2->IFG & EUSCI_A_IFG_TXIFG));
    //        EUSCI_A2->TXBUF = TXData;           // Load data onto buffer
    //
    //        __sleep();
        }
    }

  • I have attached two codes, the first one is the transmitter UART configuration, and the second one the receiver one.
  • I'm not sure I see how the transmitter (first entry) ever transmits anything, since it doesn't enable EUSCI_A_IE_TXIE and there's nothing inline. Is this the code you used for local loopback?

    Also, I have to ask: Did you remember to cross-connect (TXD->RXD in each direction) the pins between the Launchpads?

    I think you're running the UART at 3Mbps, which is pretty fast if you have long-ish cables. You might try slowing it down a little.
  • I am using the BOOSTXL-AUDIO Boosterpack for voice recognition. In my program whenever a voice is recognized it starts to transmit through UART. I did not cross-connect because I have to use PIN 3.2 and PIN 3.3 as the other pins on the top are being covered by the same BoosterPack.

                                         Audio_stopCollect(Audio);
                                         recognizeState.ledCount = 0;
                                         Leds_off1();
                                         //Leds_setColor2(0, 0, 255);
                                         while(!(EUSCI_A2->IFG & EUSCI_A_IFG_TXIFG));
                                         EUSCI_A2->TXBUF = TranData;           //TranData is the integer I want to send
                                             
    

  • All I meant by cross connect is to wire P3.2 on each board with P3.3 on the other, so TXD is connected to RXD in each direction. (It's easier to forget than it sounds.)

  • I was able to make it work. You were right the SMCLK was being divided by 16, so I change the multiplier. Thanks a lot!

**Attention** This is a public forum