Simple demo for the FRDM-KL25Z board to demonstrate communication via UART2

Dependencies:   mbed

Fork of 06_frdm_uart2 by Istvan Cserny

Communication via UART2

Simple demo to demonstrate communication via UART2 module. Wire up the arrangement, find your virtual serial port at your computer and watch the transmission by using a terminal application.

The deafault settings are: 9600 bps, 8bit, no parity, 1 stop bit.

Hardware requirements:

  • FRDM-KL25Z board
  • FTDI cable (or similar USB to UART TTL converter device)

Wiring:

  • FTDI RX to PTE22
  • FTDI TX to PTE23
  • FTDI GND to GND
  • FTDI 5V to Vin (or FTDI 3.3V to 3V3)

/media/uploads/icserny/05_frdm_uart2_bb.png

/media/uploads/icserny/05_frdm_uart2_out.png

Committer:
icserny
Date:
Mon Nov 23 11:58:02 2015 +0000
Revision:
1:03b6c60e3554
Parent:
0:307548c79526
use CR+LF convention

Who changed what in which revision?

UserRevisionLine numberNew contents of line
icserny 0:307548c79526 1 /** 06_frdm_uart2
icserny 0:307548c79526 2 * Simple demo to demonstrate communication via UART2
icserny 0:307548c79526 3 *
icserny 0:307548c79526 4 * Hardware requirements:
icserny 0:307548c79526 5 * - FRDM-KL25Z board
icserny 0:307548c79526 6 * - USB-UART protocol converter (FTDI cable or similar)
icserny 0:307548c79526 7 *
icserny 0:307548c79526 8 * Wiring:
icserny 0:307548c79526 9 * FTDI RX to PTE22, FTDI TX to PTE23
icserny 0:307548c79526 10 * FTDI GND to GND, FTDI 5V to Vin
icserny 0:307548c79526 11 */
icserny 0:307548c79526 12
icserny 0:307548c79526 13
icserny 0:307548c79526 14 #include "mbed.h"
icserny 0:307548c79526 15
icserny 0:307548c79526 16 DigitalOut myled(LED_GREEN);
icserny 0:307548c79526 17 Serial pc(PTE22, PTE23);
icserny 0:307548c79526 18
icserny 0:307548c79526 19 int main()
icserny 0:307548c79526 20 {
icserny 0:307548c79526 21 int i = 0;
icserny 1:03b6c60e3554 22 pc.printf("Hello World!\r\n");
icserny 0:307548c79526 23
icserny 0:307548c79526 24 while (true) {
icserny 0:307548c79526 25 wait_ms(1000); // wait a small period of time
icserny 0:307548c79526 26 i++; // increment the variable
icserny 0:307548c79526 27 myled = !myled; // toggle a led
icserny 0:307548c79526 28 int s = myled;
icserny 1:03b6c60e3554 29 pc.printf("%d. ledstate = %d \r\n", i,s); // print variable i and LED state
icserny 0:307548c79526 30 }
icserny 0:307548c79526 31 }