Академический Документы
Профессиональный Документы
Культура Документы
communication
Contents
Types of communication.
UART in 8051.
Max circuitry.
Programming steps.
Serial Communication
Type of Communication
1.Parallel
2.Serial
Parallel transmission
Serial transmission
Synchronous transmission
Asynchronous transmission
UART in 8051
An UART, universal asynchronous receiver /
transmitter is responsible for performing the main
task in serial communications with computers.
Controller
section
RS232
section
Baud Rates in the 8051
• The 8051 transfers and receives data serially at many
different baud rates by using UART.
• UART divides the machine cycle frequency by 32 and
sends it to Timer 1 to set the baud rate.
• Signal change for each roll over of timer 1
11.0592 MHz
Machine cycle 28800 Hz
XTAL frequency ÷ 32
÷ 12 Timer 1
oscillator 921.6 kHz By UART To timer 1
To set the
Baud rate
Baud Rates in the 8051
• SCON.1
• When the 8051 finishes the transfer of the 8-
bit character, it raises the TI flag.
• TI is raised by hardware at the beginning of
the stop bit in mode 1.
• Must be cleared by software.
RI (Receive Interrupt)
• SCON.0
• Receive interrupt flag. Set by hardware
halfway through the stop bit time in mode 1.
Must be cleared by software.
• When the 8051 receives data serially via RxD,
it gets rid of the start and stop bits and place
the byte in the SBUF register.
• Then 8051 rises RI to indicate that a byte.
• RI is raised at the beginning of the stop bit.
Transfer Data with the TI flag
• The following sequence is the steps that the 8051
goes through in transmitting a character via TxD:
1. The byte character to be transmitted is written into the
SBUF register.
2. It transfers the start bit.
3. The 8-bit character is transferred one bit at a time.
4. The stop bit is transferred.
8-bit char
SBUF
bit by bit
TI UART TxD
Steps to transmit data
from uc to pc
1.Load SCON register.
2.Laod TMOD register(select timer mode 2).
3. Load baud rate in TH.
4. Start the timer.
5. Place character in SBUF.
6. Monitor TI flag.
7. Clear TI flag.
Steps to Receive data
from pc to uc
1.Load SCON register.
2.Laod TMOD register(select timer mode 2).
3. Load baud rate in TH.
4. Start the timer.
5. Monitor RI flag.
7. Read SBUF.
8. Clear RI.
#include<reg51.h>
void main()
{
int i;
char arr[]="Advance Technology”;
TMOD=0x20; SBUF=arr[i];
SCON=0x50; while(TI==0);
TH1=0xFD; TI=0;
TR1=1; if(i==17)
while(1) TR1=0; }
{ }
for(i=0;i<=17;i++) }
{
Analog to digital
converter (ADC)
Contents
About ADC(0809).
Programming steps.
Analog to Digital Converter
An analog-to-digital converter is a device which
converts continuous signals to discrete digital
numbers. The reverse operation is performed by
a digital-to-analog converter (DAC).
8 analog
Channel
multiplexing.
Interfacing of ADC with 8051
Steps to interface 0809 ADC
with 8051 uc
1.Set initial values of SOC,EOC and OE.
2.Set ADD A, ADD B,ADD C.
3.Low to high pulse on ALE.
4.Low to high pulse on SOC with clock.
5.Monitor EOC bit.
6.Read data.
7.Repeat the steps.
#include<reg51.h>
sbit ALE=P1^3;
sbit SOC=P0^0;
sbit OE=P0^2;
sbit EOC=P0^1;
sbit SET0=P1^0;
sbit SET1=P1^1;
sbit SET2=P1^2; void main(void)
sbit CLOCK=P0^3; {