Jump to content

MSP430G2553/LaunchPad UART RX example

Recommended Posts

Just a simple UART RX example :)

Don't forget this.


void main(void)

P1DIR |= (BIT0 | BIT6);						//Set P1.0 and P1.6 to outputs

BCSCTL1 = CALBC1_1MHZ;						//Set DCO to 1MHz
P1SEL = BIT1 + BIT2;						//Set P1.1 and P1.2 to RX to TX
P1SEL2 = BIT1 + BIT2;
UCA0CTL1 |= UCSSEL_2;						//SMCLK
UCA0BR0 = 104;								//9600
UCA0BR1 = 0;								//9600
UCA0MCTL = UCBRS_1;							//Modulation
UCA0CTL1 &= ~UCSWRST;						//Start USCI
IE2 |= UCA0RXIE;							//Enable RX interrupt

__bis_SR_register(CPUOFF + GIE);			//Enter LPM0 with interrupts

//#pragma vector=USCIAB0RX_VECTOR
//__interrupt void USCI0RX_ISR(void)
if(UCA0RXBUF == 65)							//Toggle red LED if "A" RXed
	P1OUT ^= BIT0;

if(UCA0RXBUF == 66)							//Toggle green LED if "B" RXed
	P1OUT ^= BIT6;


Link to post
Share on other sites
  • 3 weeks later...

Here's a simple FreeBASIC program to toggle the LEDs:

locate 1, 1: print "connecting..."
shell "stty -F /dev/ttyACM0 speed 9600"
sleep 1000

if open com( "/dev/ttyACM0:9600,n,8,1,cs0,cd0,ds0,rs" as #1 ) <> 0 then
locate 1, 1
print "Unable to open com port"
sleep 1000
locate 1, 1: print "connected     "
end if

do while inkey$ = ""
print #1, "A";
sleep 1000
print #1, "B";
sleep 1000

close #1

Change "/dev/ttyACM0" to "COM1" for Windows, and remove "shell "stty -F /dev/ttyACM0 speed 9600"".

Link to post
Share on other sites
  • 10 months later...
  • 1 month later...



I have a Reversion 1.5 of MSP EXP430G2 board which apparently doesn't need the cross over's for hardware UART. I have the jumpers turned over for HW uart


I have compiled your code in ubuntu and transferred it to the board. 


Both the LED's RED and GREEN light up as soon as the board is powered ON.


I connect using minicom with the following code

minicom -b 9600 -D /dev/ttyACM0


As soon as the minicom connection is established the RED led switches off. Green stays ON


But when I press a or b or any other key nothing happens to the led on the boards.


When I quit minicom, both RED and GREEN are lit.


Can you suggest what I am missing to get this working.

Link to post
Share on other sites
  • 1 year later...

Hi Sir,

I am using MSP430g2231 microcontroller to generate two direction switch signal output, how to achieve

When someone by RX1, then through the RX2, D1 lit, said come into, and sent through NRF24L01,
When someone by RX2, then through RX1, D2 is lit, said Quit, and sent through NRF24L01,

If want use 6 data pipe MultiCeiver




Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...