Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 6 months ago.
How to Establish communication between two Freescale Freedom development platforms using UART.
How to Establish serial communication between two Freescale Freedom development platforms using UART.
1 Answer
6 years, 6 months ago.
Please see the serial documentation - https://os.mbed.com/docs/v5.6/reference/serial.html
You'll want to wire the boards like this:
MBED1 RX => MBED2 TX
MBED1 TX => MBED2 RX
MBED1 GND => MBED2 GND
Then, you'll want to have code running on both that uses Serial objects to handle send/receive.
- include "mbed.h"
- include "TSISensor.h"
- include "MODSERIAL.h"
- define BAUD 115200
- define TX_PIN p9
- define RX_PIN p10
DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4);
MODSERIAL pc(USBTX, USBRX);
MODSERIAL uart(TX_PIN, RX_PIN);
int main(void) { pc.PwmOut led(LED_GREEN); uart.PwmOut led(LED_GREEN); TSISensor tsi;
while (true) { if( pc.readable()) {led = 1.0 - tsi.readPercentage(); wait(0.1); uart.putc(pc.getc());} if( uart.readable()) {led = 1.0 - tsi.readPercentage(); wait(0.1); uart.putc(pc.getc());} } }
posted by 20 Nov 2017