Professional Documents
Culture Documents
Contents at a Glance
8051 Primer Board ...........................................................3
UART ...............................................................................3
RS-232 Level Converter ....................................................4
Interfacing UART .............................................................5
Interfacing UART with 8051 .............................................6
Pin Assignment with 8051 ................................................6
Circuit Diagram to Interface UART with 8051 ...................7
Source Code ....................................................................7
C Program to display a text in PC from 8051 .....................8
designs
encompassing
of
speed
8-bit
Microcontrollers.
UART
UART (Universal Asynchronous Receiver Transmitter)
are one of the basic interfaces which provide a cost
effective simple and reliable communication between one
controller to another controller or between a controller and
PC.
Join the Technical Community Today!
http://www.pantechsolutions.net
Interfacing UART
Fig. 1 shows how to interface the UART to
microcontroller. To communicate over UART or USART, we
just need three basic signals which are namely, RXD
(receive), TXD (transmit), GND (common ground). So to
interface UART with 8051, we just need the basic signals.
8051
Processor Lines
ISP PGM
RXD0
P3.0
TXD0
P3.1
RXD1
P1.2
TXD1
P1.3
UART0(P1)
UART DB-9
Connector
UART1
(P2)
8051
MAX232
Note : RXD1 and TXD1 lines are only available in Maxim-Dallas Microcontrollers
DS89C4xx series.
Source Code
The Interfacing UART with 8051 program is very simple
and straight forward, which display a text in PC from 8051
Primer Board through UART0. Some delay is occurring when
a single data is sent to PC. C programs are written in Keil
software. The baud rate of microcontroller is 9600.
Join the Technical Community Today!
http://www.pantechsolutions.net
void serial_init(void);
//------------------------------------------------//Setup the serial port for 9600 baud at 11.0592MHz.
//------------------------------------------------void serial_init(void)
{
SCON = 0x50;
/* SCON: mode 1, 8-bit UART, enable rcvr
*/
TMOD |= 0x20;
/* TMOD: timer 1, mode 2, 8-bit reload
*/
TH1 = 0xFD;
/* TH1: reload value for 9600 baud @ 11.0592MHz*/
TR1 = 1;
/* TR1: timer 1 run
*/
TI = 1;
/* TI: set TI to send first char of UART
*/
}
//-------------------------//Main Program Starts Here
//-------------------------void main(void)
{
serial_init();
printf (" PS - PrimerC51 UART Demo\n\n\r");
while (1)
{
printf ("Hello World!! \n\r"); /* Print "Hello World" */
}
}
What do we sell?
Our products range from Various Microcontroller
development boards, DSP Boards, FPGA/CPLD boards,
Communication Kits, Power electronics, Basic electronics,
Robotics, Sensors, Electronic components and much more . Our
goal is to make finding the parts and information you need
easier and affordable so you can create awesome projects and
training from Basic to Cutting edge technology.