9 years, 1 month ago.

How to change speed (baudrate) of USBSerial communication?

The default speed (baudrate) of mbed LPC1768 for the sample in the web site is 19200. I did not find a place for changing it in the codes. Could anyone help me? Thnaks.

Question relating to:

Try this in main pc.baud(115200); or any other baudrate.

posted by David Fletcher 14 Mar 2015

this does not work. the compiler returns this error: use of undeclared identifier 'pc'

posted by Ghasem Pasandi 15 Mar 2015

Then add this Serial pc(USBTX, USBRX); outside of int main(void).. Or see my answer below.

posted by David Fletcher 15 Mar 2015

1 Answer

9 years, 1 month ago.

#include "mbed.h"

DigitalOut myled1(LED1);

Serial pc(USBTX, USBRX); //use these pins for serial coms.

int main(void) {
    
   pc.baud(115200);//Set baudrate here.
    
    pc.printf("Hello World!\r\n");
   
    while(1) {
        myled1 = 1;      
        wait(0.1);
        myled1 = 0;
        wait(0.1);                
    }
}

Accepted Answer

what is the maximum baud rate accepted?

posted by Asmaa Farahat 07 Dec 2015