Serial Communication using Explore M3
In this tutorial we will see the serial communication on Explore M3 using ExploreEmbedded libraries.
Prerequisites
Please check this tutorial for detailed explanation on Lpc1768 inbuilt UART module.
If you are doing it for the first time, then check the below links to setup the project for generating the .bin file.
UART module
Explore M3 has 4-UARTs (UART0-UART3) and similarly the interfaces are suffixed with uart number.
Below table shows the Explore M3 UART pins.
UART Channel | Explore M3 Pin | LPC1768 Pin |
---|---|---|
RX0 | 0 | P0.3 |
TX0 | 1 | P0.2 |
RX1 | 6 | P0.16 |
TX1 | 7 | P0.15 |
RX2 | 4 | P0.11 |
TX2 | 5 | P0.10 |
RX3 | 2 | P0.1 |
TX3 | 3 | P0.0 |
Code
The below code shows uart communication on all the four UART channels with different baud rate.
- Note:Refer the uart.h file for interface details.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "uart.h" | |
int main() | |
{ | |
SystemInit(); | |
/* Initialize All the Four UARTs with different Baud rate */ | |
UART0_Init(9600); | |
UART1_Init(19200); | |
UART2_Init(38400); | |
UART3_Init(115200); | |
while(1) | |
{ | |
/*UARTx_Printf, where suffix "x" specifies the UART channel(0-3)*/ | |
UART0_Printf("Welcome to ExploreM3 UART Programming on channel Zero at 9600 baud\n\r"); | |
UART1_Printf("Welcome to ExploreM3 UART Programming on channel One at 19200 baud\n\r"); | |
UART2_Printf("Welcome to ExploreM3 UART Programming on channel Two at 38400 baud\n\r"); | |
UART3_Printf("Welcome to ExploreM3 UART Programming on channel Three at 115200 baud\n\r"); | |
} | |
} |