turd 31 Posted February 3, 2012 Share Posted February 3, 2012 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; } } SouLSLayeR and cekin 2 Quote Link to post Share on other sites
turd 31 Posted February 20, 2012 Author Share Posted February 20, 2012 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"". Quote Link to post Share on other sites
larsie 121 Posted February 20, 2012 Share Posted February 20, 2012 Can you use FreeBASIC on Launchpad? How do you do it? Quote Link to post Share on other sites
Vitos 1 Posted February 20, 2012 Share Posted February 20, 2012 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. Quote Link to post Share on other sites
turd 31 Posted February 20, 2012 Author Share Posted February 20, 2012 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. Quote Link to post Share on other sites
larsie 121 Posted February 21, 2012 Share Posted February 21, 2012 OK, I understand Quote Link to post Share on other sites
kiranvarma 0 Posted January 20, 2013 Share Posted January 20, 2013 Your is simple and working! I have exchange the pins of TXD and RXd as you said Thank you. Quote Link to post Share on other sites
krishnak 0 Posted February 20, 2013 Share Posted February 20, 2013 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. Quote Link to post Share on other sites
roadrunner84 466 Posted February 20, 2013 Share Posted February 20, 2013 The A or B need to be upper case! The LED change on connection is probably a glitch, it shouldn't happen. krishnak 1 Quote Link to post Share on other sites
krishnak 0 Posted February 20, 2013 Share Posted February 20, 2013 Silly me - it works with A and B Quote Link to post Share on other sites
Tyrone 0 Posted May 5, 2014 Share Posted May 5, 2014 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 RXTX.pdf Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.