• Announcements

    • bluehash

      Forum Upgrade   03/11/2017

      Hello Everyone, Thanks for being patient while the forums were being fixed and upgraded. Please see details and report issues in this thread. Thanks!
turd

MSP430G2553/LaunchPad UART RX example

11 posts in this topic

Just a simple UART RX example :)

Don't forget this.

 

#include 
#include 
//#include 
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;					//Stop WDT

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

BCSCTL1 = CALBC1_1MHZ;						//Set DCO to 1MHz
DCOCTL = CALDCO_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)
interrupt(USCIAB0RX_VECTOR) 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;
}
}

post-7895-135135536571_thumb.jpg

SouLSLayeR and cekin like this

Share this post


Link to post
Share on other sites

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

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

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"
end
else
sleep 1000
locate 1, 1: print "connected     "
end if


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

close #1

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

Share this post


Link to post
Share on other sites
Can you use FreeBASIC on Launchpad? How do you do it?

 

- It's an example algorithm for PC side of connection. It toggles LEDs by sending appropriate char through UART to the Launchpad.

Share this post


Link to post
Share on other sites
Can you use FreeBASIC on Launchpad? How do you do it?

 

- It's an example algorithm for PC side of connection. It toggles LEDs by sending appropriate char through UART to the Launchpad.

Vitos is right. I should have been more clear.

Share this post


Link to post
Share on other sites

Hi

 

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.

Share this post


Link to post
Share on other sites

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

post-36908-0-06270800-1399278124_thumb.jpg

post-36908-0-69094700-1399278126_thumb.jpg

RXTX.pdf

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now