hadiep95 0 Posted October 9, 2016 Share Posted October 9, 2016 Hello everyone, I'm new here, I have a problem when I use SoftwareSerial library to connect between MCU msp430g2553 and module GPS NEO 6M. I don't know whether this library work with MSP430 or not. When I run my code, the program stop at line while(nss.avaible()). Please help me I need some help from you. Thanks. #include <SoftwareSerial.h> SoftwareSerial nss(4,3); char gps[20]; int i; void setup() { // initialize serial: Serial.begin(9600); nss.begin(115200); Serial.write("$PMTK314,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"); Serial.write(0x0D); Serial.write(0x0A); delay(100); Serial.write("$PMTK251,9600*1F"); // 115200bps Serial.write(0x0D); Serial.write(0x0A); delay(100); Serial.write("$PMTK300,1000,0,0,0,0*1C"); Serial.write(0x0D); Serial.write(0x0A); delay(100); // reserve 200 bytes for the inputString: } void loop() { // print the string when a newline arrives: while(nss.available()) { char first = nss.read(); if(first=='$') { gps[0]= first; i=1; while (i<20) { if (nss.available()) { gps=nss.read(); i++; } } for (i = 0; i < 20; i++) { Serial.print(gps); } Serial.println(); } } } Quote Link to post Share on other sites
NurseBob 111 Posted October 10, 2016 Share Posted October 10, 2016 It seems there's some confusion about which device you're having your serial conversation with. I think that nss is intended to talk to your gps, but you're directing the gps commands to the hardware Serial in your setup code? So, when you get to the loop() code, which is looking for nss to report it has data, it has none, thus it doesn't progress. HTH Quote Link to post Share on other sites
roadrunner84 466 Posted October 10, 2016 Share Posted October 10, 2016 It looks like you're using software serial, but try to initialize your GPS module using hardware serial. Should the setup not call nss.write() all the time, instead of Serial.write()? energia 1 Quote Link to post Share on other sites
energia 485 Posted October 10, 2016 Share Posted October 10, 2016 In addition, you are initializing SoftwareSerial on pins 3 and 4. Pins 3 and 4 are already allocated to the Hardware Serial. Try using e.g. pins 7 and 8. Quote Link to post Share on other sites
abecedarian 330 Posted October 14, 2016 Share Posted October 14, 2016 G2553 has two hardware serial, no?So why use software serial if the hardware supports it? Quote Link to post Share on other sites
roadrunner84 466 Posted October 17, 2016 Share Posted October 17, 2016 G2553 has two hardware serial, no? So why use software serial if the hardware supports it? No it doesn't. It does have a dual serial interface, but only one can be set to UART, the other can be set to I2C, both can be set as SPI. Quote Link to post Share on other sites
Fmilburn 446 Posted October 17, 2016 Share Posted October 17, 2016 I have successfully used this library with the NEO 6M, Energia and a F5529: https://github.com/anorse/NorseEngineering_GPS If I remember correctly, all I had to do was change my the pins. It may work with the G2553. 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.