Troubles establishing serial communication

04 Apr 2010

Lets try this on this forum instead...

Hi all, I have two mbeds, and I'm trying to establish a serial connection between these. I have them connected p13->p14, p14->p13, and have verified continuity. I'm running a basic test code, which is this-

 

#include "mbed.h"

Serial othermbed(p13 ,p14);

DigitalOut LEDext(LED1);

char x;

 

int main()

{

while(1)

{

othermbed.putc('c');           // character written to other mbed via serial

x = (othermbed.getc());

if (x == 'g')

{

LEDext = 1;

}

else

{

LEDext = 0;

}

}

}

 

However this does nothing when compiled and run. This obviously isn't the purpose of establishing a serial connection, just the most basic test program I could devise.

 

If somebody has a pair of mbeds out there, would you mind quickly patching this up and trying it for me please?

 

Thanks,

 

Simon

 

04 Apr 2010

http://mbed.org/handbook/SerialPC

 

See the loop back operation further down, try this but across the 2 boards.

04 Apr 2010

Thanks Andrew, I'll give it a go, but I've never tried using the USB interface, so I don't know how I'll get on.

Can you see any reason the above code shouldn't work?

05 Apr 2010

Simon,

 

Unless the constructor sets the baud rate by default you possibly need to set it explicitly.

05 Apr 2010

Unless I've missed the point, surely this shouldn't do anything (change the LEDs) as c != g. Default baud rate is 9600

05 Apr 2010 . Edited: 05 Apr 2010

Ah yes, I've just noticed the embarrassing error here...both boards sending a c and looking for a g. Whoops. Now works fine. Have to learn C somehow!

 

Thanks all.