11 years, 4 months ago.

Serial Comm Error LPC1768 - Invalid Stop Bit Setting - LEDs 1 and 4 alternate flashing with 2 and 3

When I load a program that uses time, LEDs 1 and 4 alternate flashing with 2 and 3. My program does not run. It was running fine since I last programmed. I loaded a program that doesn't use time and it ran fine. Loaded a known working version of code instead of my latest and it does the same thing. Is there a way to reset the clock?

Any help would be great!

//=====================DEBUG SYSTEM DEFINES==================================//
// UNCOMMENT LINES TO TURN ON                                               =//
// COMMENT LINES TO TURN OFF                                                =//
//===========================================================================//
#define DEBUG_CODE_ENABLE 
#define LED_DISPLAY_ENABLE
//#define ASCII_INPUT

//===========================================================================//
#define DEBUG_SERIAL_BAUD_RATE 115200       // Debug serial port baud rate
#define DEBUG_SERIAL_BITS      8            // Debug serial number of bits in a word (5-8; default = 8) 
#define DEBUG_SERIAL_PARITY    Serial::None // Debug serial port parity
#define DEBUG_SERIAL_STOP_BITS 1            // Debug serial port stop bits (1 or 2; default = 1)

//===========================================================================//
#define RADIO_SERIAL_BAUD_RATE 4800         // Radio serial port baud rate
#define RADIO_SERIAL_BITS      8            // Radio serial number of bits in a word (5-8; default = 8) 
#define RADIO_SERIAL_PARITY    Serial::None // Radio serial port parity
#define RADIO_SERIAL_STOP_BITS 1            // Radio serial port stop bits (1 or 2; default = 1)

//===========================================================================//
#define SENSR_SERIAL_BAUD_RATE 9600         // Sensor serial port baud rate
#define SENSR_SERIAL_BITS      8            // Sensor serial number of bits in a word (5-8; default = 8) 
#define SENSR_SERIAL_PARITY    Serial::Even // Sensor serial port parity
#define SENSR_SERIAL_STOP_BITS 0            // Sensor serial port stop bits (1 or 2; default = 1)

//===========================================================================//
#define HEARTBEAT_TIME         60           // Time in seconds to periodically send current data
#define DELTA_THRESHOLD        2            // Two units of difference in sensor data 




1 Answer

11 years, 4 months ago.

That flash pattern is what happens when an error is encountered during runtime. Without the code we can't know what it is, so it would help if you post that (between <<code>> <</code>>, which need to be on seperate lines).

To get a clue what is going wrong, open your normal terminal program and look what comes back (just 9600 baudrate, unless you specified something else in your program). Normally errors send a message over the default IO (and they have the irritating habbit of being cut-off, so you dont see the complete message).

Edit: Tested your code (it isnt complete, but was enough to reproduce the problem). And the message I get is: "Invalid stop bit". Quick check then show you have for your sensor serial connection 0 stop bits, which isnt allowed. That is causing the error, not the time code.

Accepted Answer

Updated my question with the code. I am using all three serial channels, is there another connection you are referring to that runs at 9600 baud?

Thanks for your help!

posted by Daniel Penny 28 Dec 2012

It is send over whatever one is defines as standard output, if no library changes that it will be the USB serial output. So just pc in your case, and will go at the baudrate specified for pc. Edit: Looked wrong, it goes over USBTX, USBRX, and generally that is what people name pc, but not in your case. So it will go at 9600 baud over the USB port.

posted by Erik - 28 Dec 2012

See edit of my original answer :)

posted by Erik - 28 Dec 2012

Erik,

Thank you very much for helping with that. If I were to define a serial interface using USBTX and USBRX, would that have enabled me to see the error message indicating "invalid stop bit"? I would like to learn how to use the standard debugging error message for future. I will look it up, but are there docs that point this out?

Once again, thanks for helping me out!

Cheers, Daniel

posted by Daniel Penny 28 Dec 2012

You dont have to define it, it goes automatically to it. So if you just hook up the mbed serial via USB you get it on your screen, even if you dont add anything in your code. See: http://mbed.org/handbook/SerialPC.

You can test it yourself then by adding an error in your code like this:

error("This is a test");
posted by Erik - 28 Dec 2012