FRDM-K64 Serial communication basic example using mbed

Document created by Pedro Augusto Panecatl Salas Employee on Jun 27, 2014Last modified by Pedro Augusto Panecatl Salas Employee on Jun 29, 2014
Version 2Show Document
  • View in full screen mode

Here you can find both the code and project files for the Serial communication project, in this example the serial port (UART) is configured to establish communication between the computer using a serial terminal and the evaluation board. The default baud rate for the serial port is 9600 bauds. The code also implements an echo function, any key pressed in the computer's keyboard will be captured and displayed in the serial terminal.

 

If your computer does not have a serial terminal you can download Tera Term from the following link:

Tera Term Open Source Project

 

The communication is established through the USB cable attached to the OpenSDA USB port.

 

Code:

 

#include "mbed.h"

 

//Digital output declaration

DigitalOut Blue(LED3);

 

//Serial port (UART) configuration

Serial pc(USBTX,USBRX);

 

int main()

{

    Blue=1;

    pc.printf("Serial code example\r\n");   

    while(1)

    {

        Blue=0;

        pc.putc(pc.getc());

    }

  

}

Outcomes