0% found this document useful (0 votes)
44 views9 pages

Max 232

The document outlines the requirements and components necessary for serial communication using a microcontroller, including the use of RS232 cables and MAX232 IC for voltage level conversion. It explains the function of key registers such as TMOD, SCON, and SBUF in managing timers and data transmission. Additionally, it distinguishes between asynchronous and synchronous communication methods, detailing the setup for interfacing a microcontroller with external devices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views9 pages

Max 232

The document outlines the requirements and components necessary for serial communication using a microcontroller, including the use of RS232 cables and MAX232 IC for voltage level conversion. It explains the function of key registers such as TMOD, SCON, and SBUF in managing timers and data transmission. Additionally, it distinguishes between asynchronous and synchronous communication methods, detailing the setup for interfacing a microcontroller with external devices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

SERIAL COMMUNICATION:

The main requirements for serial communication are:

1. Microcontroller

2. PC or any external device which can be interfaced with the microcontroller through
serial communication.

3. RS 232 cable

4. MAX 232 IC

5. HyperTerminal

When the pins P3.0 and P3.1 of microcontroller are set, UART which is inbuilt in the
microcontroller will be enabled to start the serial communication.

The three major registers used for Serial Communication are:

1. TMOD to select the timer.


2. SCON for data framing.

3. SBUF which is solely used for Serial Communication.

SBUF (Serial Buffer) is an 8-bit register used while transmitting or receiving the data.
Whenever the microcontroller tries to transmit any data, the data should be first placed
into SBUF register. Thus, it is the duty of SBUF to transmit the data to PC.

Similarly, while the microcontroller received the data from PC, the data coming from the
PC first falls into SBUF register and from there, the microcontroller reads the received
data from PC.
TIMERS:

The 8051 has two timers: Timer 0 and Timer 1. They can be used either as timers to
generate a time delay or as counters to count events happening outside the
microcontroller.

Both Timer 0 and Timer 1 are 16-bit wide. Since the 8051 has an 8-bit architecture, each
16-bit timer is accessed as two separate registers of low byte and high byte.

Lower byte register of Timer 0 is TL0 and higher byte is TH0. Similarly lower byte
register of Timer1 is TL1 and higher byte register is TH1.

TMOD (timer mode) register:

Both timers 0 and 1 use the same register TMOD to set the various operation modes.

TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and
the upper 4 bits for Timer 1. In each case, the lower 2 bits are used to set the timer mode
and the upper 2 bits to specify the operation.

(MSB) (LSB)

GATE C/T M1 M0 GATE C/T M1 M0

TIMER 1 TIMER 0
GATE

Every timer has a means of starting and stopping. Some timers do this by software, some
by hardware and some have both software and hardware controls. The timers in the 8051
have both. The start and stop of the timer are controlled by the way of software by the TR
(timer start) bits TR0 and TR1. These instructions start and stop the timers as long as
GATE=0 in the TMOD register. The hardware way of starting and stopping the timer by
an external source is achieved by making GATE=1 in the TMOD register.

C/T

Timer or counter selected. Cleared for timer operation and set for counter operation.

M1

Mode bit 1

M0

Mode bit 0

M1 M0 Mode Operating Mode

0 0 0 13-bit timer mode

8-bit timer/counter THx with TLx as 5-bit prescaler

0 1 1 16-bit timer mode

16-bit timer/counters THx and TLx are cascaded

1 0 2 8-bit auto reload timer/counter

THx holds a value that is to be reloaded into TLx each time

it overflows
1 1 3 Split timer mode

The mode used here to generate a time delay is MODE 2.

This mode 2 is an 8-bit timer and therefore it allows only values of 00H to FFH to be
loaded into the timer’s register TH. After TH is loaded with the 8-bit value, the 8051 give
a copy of it to TL. When the timer starts, it starts to count up by incrementing the TL
register. It counts up until it reaches its limit of FFH. When it rolls over from FFH to
00H, it sets high the TF (timer flag). If Timer 0 is used, TF0 goes high and if Timer 1 is
used, TF1 goes high. When the TL register rolls from FFH to 0 and TF is set to 1, TL is
reloaded automatically with the original value kept by the TH register.

ASYNCHRONOUS AND SYNCHRONOUS SERIAL COMMUNICATION

Computers transfer data in two ways: parallel and serial. In parallel data transfers, often 8
or more lines are used to transfer data to a device that is only a few feet away. Although a
lot of data can be transferred in a short amount of time by using many wires in parallel,
the distance cannot be great. To transfer to a device located many meters away, the serial
method is best suitable.

In serial communication, the data is sent one bit at a time. The 8051 has serial
communication capability built into it, thereby making possible fast data transfer using
only a few wires.

The fact that serial communication uses a single data line instead of the 8-bit data line
instead of the 8-bit data line of parallel communication not only makes it cheaper but also
enables two computers located in two different cities to communicate over the telephone.
Serial data communication uses two methods, asynchronous and synchronous. The
synchronous method transfers a block of data at a time, while the asynchronous method
transfers a single byte at a time. With synchronous communications, the two devices
initially synchronize themselves to each other, and then continually send characters to
stay in sync. Even when data is not really being sent, a constant flow of bits allows each
device to know where the other is at any given time. That is, each character that is sent is
either actual data or an idle character. Synchronous communications allows faster data
transfer rates than asynchronous methods, because additional bits to mark the beginning
and end of each data byte are not required. The serial ports on IBM-style PCs are
asynchronous devices and therefore only support asynchronous serial communications.

Asynchronous means "no synchronization", and thus does not require sending and
receiving idle characters. However, the beginning and end of each byte of data must be
identified by start and stop bits. The start bit indicates when the data byte is about to
begin and the stop bit signals when it ends. The requirement to send these additional two
bits causes asynchronous communication to be slightly slower than synchronous however
it has the advantage that the processor does not have to deal with the additional idle
characters.

There are special IC chips made by many manufacturers for serial data communications.
These chips are commonly referred to as UART (universal asynchronous receiver-
transmitter) and USART (universal synchronous-asynchronous receiver-transmitter). The
8051 has a built-in UART.

In the asynchronous method, the data such as ASCII characters are packed between a
start and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits.
The start bit is always a 0 (low) and stop bit (s) is 1 (high). This is called framing.

The rate of data transfer in serial data communication is stated as bps (bits per second).
Another widely used terminology for bps is baud rate. The data transfer rate of a given
computer system depends on communication ports incorporated into that system. And in
asynchronous serial data communication, this baud rate is generally limited to
100,000bps. The baud rate is fixed to 9600bps in order to interface with the
microcontroller using a crystal of 11.0592 MHz.

RS232 CABLE:

To allow compatibility among data communication equipment, an interfacing standard


called RS232 is used. Since the standard was set long before the advent of the TTL logic
family, its input and output voltage levels are not TTL compatible. For this reason, to
connect any RS232 to a microcontroller system, voltage converters such as MAX232 are
used to convert the TTL logic levels to the RS232 voltage levels and vice versa.

MAX 232:

Max232 IC is a specialized circuit which makes standard voltages as required by RS232


standards. This IC provides best noise rejection and very reliable against discharges and
short circuits. MAX232 IC chips are commonly referred to as line drivers.

To ensure data transfer between PC and microcontroller, the baud rate and voltage levels
of Microcontroller and PC should be the same. The voltage levels of microcontroller are
logic1 and logic 0 i.e., logic 1 is +5V and logic 0 is 0V. But for PC, RS232 voltage levels
are considered and they are: logic 1 is taken as -3V to -25V and logic 0 as +3V to +25V.
So, in order to equal these voltage levels, MAX232 IC is used. Thus this IC converts
RS232 voltage levels to microcontroller voltage levels and vice versa.
Fig: Pin diagram of MAX 232 IC

INTERFACING MAX232 WITH MICROCONTROLLER:

SCON (serial control) register:

The SCON register is an 8-bit register used to program the start bit, stop bit and data bits
of data framing.

RI TI RB8 TB8 REN SM2 SM1 SM0

SM0 SCON.7 Serial port mode specifier

SM1 SCON.6 Serial port mode specifier

SM2 SCON.5 Used for multiprocessor communication

REN SCON.4 Set/cleared by software to enable/disable reception


TB8 SCON.3 Not widely used

RB8 SCON.2 Not widely used

TI SCON.1 Transmit interrupt flag. Set by hardware at the

beginning of the stop bit in mode 1. Must be

cleared by software.

RI SCON.0 Receive interrupt flag. Set by hardware at the

beginning of the stop bit in mode 1. Must be

cleared by software.

SM0 SM1

0 0 Serial Mode 0

0 1 Serial Mode 1, 8-bit data, 1 stop bit, 1 start bit

1 0 Serial Mode 2

1 1 Serial Mode 3

Of the four serial modes, only mode 1 is widely used. In the SCON register, when serial
mode 1 is chosen, the data framing is 8 bits, 1 stop bit and 1 start bit, which makes it
compatible with the COM port of IBM/ compatible PC’s. And the most important is
serial mode 1 allows the baud rate to be variable and is set by Timer 1 of the 8051. In
serial mode 1, for each character a total of 10 bits are transferred, where the first bit is the
start bit, followed by 8 bits of data and finally 1 stop bit.
MICROCONTROLLER INTERFACE WITH ANY EXTERNAL DEVICES
USING SERIAL COMMUNICATION:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy