Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 2 months ago.
Why does this Serial declaration keep my code from running?
This code runs fine:
#include "mbed.h" //Serial GPS(p9,p10); Serial pc(USBTX, USBRX); // tx, rx DigitalOut GPS_switch(p5); DigitalIn pps(p12); char x; int main() { GPS_switch=0; wait(1); pc.printf("start pulse\n"); GPS_switch = 1; wait(0.1); GPS_switch = 0; pc.printf("stop pulse\n"); while(!pps); pc.printf("got pps\n"); //GPS.baud(4800); //while(1){ //GPS.getc(); //pc.printf("%c",x); } }
outputs something like:
start pulse stop pulse got pps
then this code does not work
#include "mbed.h" Serial GPS(p9,p10); Serial pc(USBTX, USBRX); // tx, rx DigitalOut GPS_switch(p5); DigitalIn pps(p12); char x; int main() { GPS_switch=0; wait(1); pc.printf("start pulse\n"); GPS_switch = 1; wait(0.1); GPS_switch = 0; pc.printf("stop pulse\n"); while(!pps); pc.printf("got pps\n"); //GPS.baud(4800); //while(1){ //GPS.getc(); //pc.printf("%c",x); } }
To reduce confusion I left out any operations on that GPS Serial object. The output is blank. No messages. In Real Term it outputs Null. In both cases The GPS unit Does power on
Cant really move forward... any help appreciated!
Question relating to:
1 Answer
11 years, 2 months ago.
Hi, If this is running on the LPC11U24 M0 mbed then the USB TX and RX are shared with P9 & P10 so you can't use both at the same time - it will cause the program to hang...
sorry about the format, I though bbcode worked here. Ive never posted my code before
posted by Andrew Miller 25 Feb 2013Use
posted by Erik - 25 Feb 2013<<code>> and <</code>>
to make code blocks (on seperate lines).I have edited your question to include the code blocks. The syntax is just slightly different to bbcode.
posted by Tharshan M 26 Feb 2013