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/MSP430G2553: SIMPLE UART RECEIVER PROGRAM

Part Number: MSP430G2553


Tool/software: Code Composer Studio

HEY,

  i am looking for a simple uart receiver program for studying. can anyone help me?

  • I suggest you start with Example msp430g2xx3_uscia0_uart_01_115k.c (or similar) here:

    http://dev.ti.com/tirex/explore/node?node=ALFfIDtjUH-HwRytz.WJPQ__IOGqZri__LATEST

    The Echo part is in the ISR, where you see UCA0TXBUF=UCA0RXBUF. Replace that with code to do what you want.

  • Hey, 

          Thank you for the help. The uart receiving data is repeatedly coming.what to do if i want to receive only once without interrupt?

  • I'm not sure I understand. Are you seeing data at your PC even if you don't type anything? Have you changed anything in the program?

    If you don't want to use interrupts, you can poll for receive data in main(). 

    1) Remove the line referring to UCA0RXIE

    2) In main() insert a polling loop something like:

      while (!(IFG2 & UCA0RXIFG)) /*EMPTY*/;   // spin until Rx data appears
      RxByte = UCA0RXBUF;    // Capture Rx data
    

    Polling for Rx data is uncommon since in most applications it's unpredictable when the Rx data will arrive.

    If you can tell us your overall goal, we can guide you a little better.

    [Edit: Fixed code -- wrong MCU.]

  • HEY,

    Thanks for your reply. How can i make keyboard alphabet as a interrupt. i.e when i press alphabet "A" it should be shown "A" once and then run the main program as it runs before. can you help me with the code?

  • I'm not quite sure I understand what you want to do.

    The Example I mentioned above (unchanged) does what I think you're describing -- you connect the USB ("backchannel UART) to a terminal emulator on a PC, and whatever you type is echoed back to you. In between characters, it runs whatever code is in main (right now that isn't much, but you can add things).This is fairly cumbersome to accomplish without interrupts.

**Attention** This is a public forum