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.

MSP430FR5972: UART_Rx_issue

Part Number: MSP430FR5972


I want to type a string at console window (Tera Term or Bray's Terminal) and want to store in any array and transmit the same on the console window.  

I can print any single character, string or integer on console window using UART Tx but stuck in Rx (multibyte). 

can any one send me the example code I unable to find on the internet 

 

  • Hi PK!

    If single byte recepton works, then you simply might not clear the buffer fast enough. If you show your code, we can have a look at it.

    Dennis
  • below mention code for one character & it is working

    unsigned char test;
    test = uart_read(); // this API to receive the data
    if (test == 'a')
    uartPutString("working"); // this API to print the string
    else
    uartPutString("Not Working");

    below mention code which I am trying to do for receive multiple character but not working

    do
    {
    while(!(UCA0IFG & UCRXIFG));

    arr[k] = uart_read(); // trying to receive in arr[]
    k++;
    }while(arr[k]!=0x0D); // data should stop storing in arr[] if enetr key pressed from keyboard
    uartPutString(arr); // should be print the same data on console window


    I am using below mention ISR for multibyte receive UART


    /*****************************UART Interrupt*************************************/

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG))
    {
    case USCI_NONE: break;
    case USCI_UART_UCRXIFG:
    __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 on reti
    }
    }
  • I'm not entirely sure at the moment, but doesn't reading the UCA0IV clear the RX flag? Please look that up in the user's guide - I cannot do that at the moment. If so, then your code will hang in the first line of your do-loop because the RX flag will always be cleared in the ISR. Could you try without the ISR? Or, in there, only check if the flag is set without reading the IV?
  • Sorry Dennis actually I unable to understand your explaination can you plz fix my problem
  • First start without the sleep mode and disable the RX interrupt. Does only polling work then?

**Attention** This is a public forum