11 years ago.

understanding serial over usb and putc

Hi, newbie here.

I found one of your sample programs that simply sends back characters received using getc() and putc() using USBTX and USBRX. I downloaded it to the LPC1768, I think successfully. On Ubuntu, when I open /dev/ttyACM0 with minicom, the blue light on the mbed blinks each time I press a key, but I never see anything coming back.

Should I expect the putc() to send the char over the USB connection to minicom, or does putc instead go to some pin, or do I need other wiring and chips to make this work ? I am unclear after reading a lot of posts. All I have is a USB cable from the mbed to the PC.

I want the mbed to echo back characters that I send over the USB (serial).

Thanks, mark

Hello Mark Willis,

don't need to wire anything more. Can you share the link to the demo you are running?

posted by Martin Kojtal 21 Nov 2013

Here is the demo I am running now: http://mbed.org/handbook/USBSerial

I am trying the program USBSerial_HelloWorld It compiles fine. Then I transfer it to the device like this:

download command

sudo dd if=PROGRAM_NAME.bin of=/dev/disk/by-label/MBED seek=4

I reset the mbed, open /dev/ttyACM0 with minicom 9600,8,n,1. I understand 9600,n,8,1 is the default. I think I should be receiving a repeating message "I am a virtual serial port\r\n", but I receive nothing, Everytime I press a key the mbed LED blinks.

Should I expect to receive the message back and view it in the serial terminal ? Thanks for any tips.

posted by mark willis 21 Nov 2013

You should see the message echoed back when all is well. You say the blue power LED is blinking when you press a key. That means mbed is receiving a char. I am not very familiar with mbed on linux, so are you sure that you have a running bin file. Do you see the new bin on the mbed thumbstick? Did you press resetbutton or powercycle the mbed to make sure it is running. Can you get an mbed program to flash any of the 4 user LEDs in this way? Maybe there is an issue with linux buffering and you need to flush the buffer. Adding \n\r to each char should do that.

posted by Wim Huiskamp 21 Nov 2013

I see my new bin on the mbed mass storage. I tried pressing the reset button and unplugging. I will try to flash the LEDs. I do type sync to flush after downloading, and I press return and control+J after typing characters. But this program takes no input, I should just see a stream of messages from the mbed. Thanks.

posted by mark willis 21 Nov 2013

You got the wrong program :)

USBSerial does a serial connection over the USB port of the microcontroller itself. For your LPC1768 that means the D+ and D- pins, which you can connect to a USB connector. The USB port on your mbed is connected to an interface chip. If you want to use that one you need to use: http://mbed.org/users/mbed_official/code/Serial_HelloWorld_Mbed/

posted by Erik - 21 Nov 2013

Thank you ! I am receving text now. This (Serial_HelloWorld_Mbed) is the same program I started with, but before running it this time I did two things differently: 1 I reformatted the mass storage 2 I simply used the file explorer to copy the bin to the mass storage, instead of the dd command.

posted by mark willis 21 Nov 2013

2 Answers

11 years ago.

Check the baudrate, stopbit setting for minicom. Does is match the (default) setting of the mbed Serial object.

mark willis
poster
11 years ago.