Serial Library

31 Aug 2009 . Edited: 31 Aug 2009

this is my code

#include "mbed.h"

Serial mc(9, 10);
int main() {

mc.baud(19200);
mc.putc(0xC2);
mc.putc(0x7F);
}

i am using V11 of the library when i compiler and load the program the code works but the buttom LED's are flashing in a certain pattern i have not written any code for them as u can see. they o that with every program

if i was to use V12 of the library i get this error

"No instance of constructor "mbed::Serial::Serial" matches the argument list (E289)" in file "xxx/main.cpp"

"            ^ (E0)" in file "xxx/main.cpp"

please help

31 Aug 2009

Hi Oliver,

this is my code

#include "mbed.h"

Serial mc(9, 10);
int main() {

mc.baud(19200);
mc.putc(0xC2);
mc.putc(0x7F);
}

i am using V11 of the library when i compiler and load the program the code works but the buttom LED's are flashing in a certain pattern i have not written any code for them as u can see. they o that with every program

I reproduced this program at http://mbed.org/users/simon/published/db09f76468165c304b02000516691530/SerialTestv11.zip for reference. The "certain pattern" you are seeing is our "siren lights" or "blue lights of death", indicating a runtime error (see http://mbed.org/handbook/Debugging).

However, the reason you are getting it is actually just because you are returning from main (after the last mc.putc). In the v11 libraries, and return from main caused this. Most people never return from main i.e. the program runs for ever.

The v12 libraries correct this "bug", and now if you return 0 from main or call exit(0);, it will be considered normal and just wait forever, and a non-0 return or exit will cause the siren lights.

if i was to use V12 of the library i get this error

"No instance of constructor "mbed::Serial::Serial" matches the argument list (E289)" in file "xxx/main.cpp"

"            ^ (E0)" in file "xxx/main.cpp"

This is because you haven't updated the pin names, which have changed in v12. The code should be:

Serial mc(p9, p10); // tx, rx

This should then work fine! This updated example can be found at http://mbed.org/users/simon/published/42601b80fcb8ca9651b9bced105a7651/SerialTestv12.zip

We'll make sure we do a full explanation and sweep of the site re: pin names, as I expect it'll keep tripping people up for a while...

Hope this helps. Please say if anything is not clear.

Simon