UART(Universal Asynchronous Receiver-Transmitter)

A UART(Universal Asynchronous Receiver-Transmitter) is a computer hardware device for asynchronous serial communication in which the data format and transmission speeds are configurable. The electric signaling levels and methods are handled by a driver circuit external to the UART. A UART is usually an individual (or part of an) integrated circuit (IC) used for serial communications over a computer or peripheral device serial port.

Let us write and implement a test program for a UART.

Step 1: Create a uart.c File

Step 2: Write the following code into the File

#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<termios.h>
#include<string.h>
int main(int argc, char * argv[])
{
	int fd;
	fd = open("/dev/ttyS3",O_RDONLY|O_NOCTTY);
	if(fd == -1)
	{
		printf("\n Error! in Opening ttyS3");}
	else{
		printf("\n ttyS3 Opened Successfully");}
	close(fd);
}

Step 3: Open Terminal and navigate to your Toolchain folder

Step 4: Run the "env.sh" file using the command . env.sh to enable the Toolchain To make sure the toolchain is runnig type in "arm" and hit the <TAB> key twice.

Step 5: To create a binary named uart from "uart.c" arm-linux-gnueabi-gcc uart.c -o uart

Step 6: Transfer the compiled binary to the Board using TFTP or SD card.

Step 7: Run the binary file sudo ./uarton the Board's Terminal.

Last updated