MediaTek LinkIt™ Smart 7688 Developer's Guide
© 2015, 2016 MediaTek Inc.
Page 76
This document contains information that is proprietary to MediaTek Inc.
Unauthorized reproduction or disclosure of this information in whole or in part is strictly prohibited.
6.5.
Programming with Primitive UART Connection
In all the scenarios described in previous section, the MPU and MCU on LinkIt Smart 7688 Duo
communicates using Serial port. The MCU communicates with OpenWrt Linux over UART
hardware. Table 17 illustrates the communication between MCU and MPU:
MCU
MPU
In Arduino
Serial1
In Linux
/dev/ttyS0
Corresponding Pins
D0 and D1
Pin MUX
UART0 (GPIO12 and
GPIO13)
Table 17 MCU and MPU Communication
In the following section an example is provided to demonstrate how to communicate between the
MCU and MPU side by writing to and reading from the primitive UART connection.
6.5.1.
Blink Program - Arduino Side
The MCU side is written as an Arduino sketch. In this example, the sketch simply listens to the
command sent from the MPU (Linux) side and switches the on-board LED accordingly.
1)
First, connect the LinkIt Smart 7688 Duo to your PC, then open Arduino IDE and paste the
following sketch code into the IDE:
void setup() {
Serial.begin(115200); // open serial connection to USB Serial port
(connected to your computer)
Serial1.begin(57600); // open internal serial connection to MT7688
// in MT7688, this maps to device
pinMode(13, OUTPUT);
}
void loop() {
int c = Serial1.read(); // read from MT7688
if (c != -1) {
switch(c) {
case '0': // turn off D13 when receiving "0"
digitalWrite(13, 0);
break;
case '1': // turn off D13 when receiving "1"
digitalWrite(13, 1);
break;
}
}
}
2)
Then choose the correct COM port from the IDE (check your device manager) by clicking
Tools > Port
.
3)
Upload the sketch to the board as shown in Figure 56. Note the board is not blinking yet –
you’ll need to write a program in the Linux side to make it blink, which is the next step.