Microprocessors - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

Microprocessors

Description:

Baud Rate ... 3. Get the timer preset by dividing the UART frequency by the baud rate. ... Baud Rate Presets with 12MHz system clock (SMOD = 0). 16. RS232 Standards ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 57
Provided by: davidlk2
Category:

less

Transcript and Presenter's Notes

Title: Microprocessors


1
Microprocessors
  • 8051 Serial Communication Ch10

2
Serial Transfer
  • Single line
  • Cheaper than parallel transfer
  • Slower than parallel transfer
  • Synchronous transfers a block of characters
  • Asynchronous transfers a single character
  • Basic method is called Simplex one way
    communication.

3
Serial Transfer Hardware
  • UART Universal asynchronous R/T (on 8051)
  • USART Universal synchronous/asynchronous R/T
  • Modem (modulator/demodulator) for long distance
    (telephone) communication.

4
Full Duplex
  • Requires two parallel paths
  • Allows communication both ways at the same time.

5
Half Duplex
  • Tx and Rx at all stations.
  • Only one path (as in simplex)
  • Data goes only one way at a time.

6
Communication Protocol
  • A protocol is an agreed upon plan established by
    usage or convention or treaty.
  • Authorities attempt to teach us manners which
    is another name for protocol.
  • A communication protocol is needed for
    comfortable and productive conversation.
  • Recall examples of commonly accepted
    communication protocol that you use often.

7
  • Start and stop bits frame the data.
  • Signal is high (Mark) until data is sent.
  • Space is low.

Frame
8
Asynchronous Data Framing Protocol
  • Mark is High
  • Space is Low
  • 1 or 2 stop bits
  • 7 or 8 data bits

9
Baud Rate
  • For practical purposes and unless otherwise
    stated, the baud rate is the number of bits
    transferred per second (bps).
  • 100,000 baud is about max for asynchronous serial
    com.
  • Where did they get the word baud?

10
Baud rate depends on THREE settings.
  • Frequency of system clock oscillator. Can be
    changed by changing crystal.
  • SMOD
  • if 0 divide by 32
  • if 1, divide by 16
  • Timer Preset.

11
8051 Baud Rate Preset
  • 1. Get the machine cycle frequency by dividing
    the system clock frequency by 12.
  • 2. Get the UART frequency by dividing the machine
    cycle frequency by 32
  • (SMOD 0).
  • 3. Get the timer preset by dividing the UART
    frequency by the baud rate.
  • The timer preset is 3 or FDH. This gives an
    acutal baud rate of 10417.

12MHz/12 1MHz
1MHz/32 31.25KHz
31.25KHz/9600 3
12
Determining the duration of a machine cycle.
  • There are 12 system oscillator cycles per machine
    cycle.
  • Divide the system oscillator frequency by 12

12/16MHz 0.75uS12/12MHz 1uS12/11.0592MHz
1.085uS
13
Determining the duration of a machine cycle.
  • Multiply the period of the system oscillator by
    12.

16MHz/12 1.333MHz12MHz/12 1MHz11.0592MHz/12
0.9216MHz
14
Determine UART
15
Baud Rate Presets with 12MHz system clock (SMOD
0).
16
RS232 Standards
  • Most widely used serial standard.
  • Mark is 3V to 25V
  • Space is 3V to 25V
  • Need a line driver to make it compatible with
    TTL standard. (MAX232)

17
RS232 Male Connectors
GND
RxD, TxD
DB-9
TxD, RxD
GND
DB-25
18
Female Serial Connection
GND
Tx
Rx
19
RS232 and 8051
  • Requires a linedriver such as MAX232 chip.

20
Serial Control RegisterSCON
1 A byte is ready to go.0 A byte is not
ready.
1 A Byte has been received0 Waiting to
receive a byte.
SM0,SM1,SM2
Set for common framing.
Receiver Enable1 Listening. 0 Not listening.
21
Serially Transmit a Character
Puts 0010 0000 in TMOD to make timer 1 8-bit auto
reload.
22
Puts 6 in TH1 to produce 9600 baud rate
continuously.
23
Puts 0101 0000 in SCON to set framing, enable
REN, and clear both TI, RI
24
Starts timer 1 to generate baud rate.
25
Wave bye-bye to ASCII A
26
Wait till here SBUF empties.
27
We know its gone when TI 1
28
Now that SBUF is empty, reset TI.
29
Lets do it again!
30
Put a byte into SBUF.
31
Wait until it transmits (thats automatic).
32
It is done transmitting when TI sets.
33
Reset the transmit flag.
34
Do it again.
35
Load SBUF.
36
Wait for TI.
37
When TI sets, proceed with the program.
38
Reset IT every time it sets.
39
Try it. Copy and paste into an .asm file. Open a
TTY window to see the action.
include ltsfr51.incgt
cseg at 0
org 0 MOV TMOD, 20H
MOV TH1,-3
MOV SCON,50H
SETB TR1 AGAIN MOV SBUF,'A' HERE
JNB TI, HERE CLR
TI SJMP AGAIN
end
40
Serially Receive a Character
Timer1 is 8-bit automatic reload.
41
Timer1 preset is 3 for 9600 baud.
42
Plan for 8 data bits, 1 stop bit, enable the
receiver (REN).
43
Turn the timer on.
44
Waste time until a byte is received.
45
Hey, theres data in my SBUF!
46
Copy it right away so SBUF can be used again.
47
Give P1 a copy.
48
Should have done this after MOV A, SBUF.
49
Go back for another byte.
50
Wait here for another byte.
51
Another byte has arrived.
52
Move it to the accumulator.
53
Give P1 a copy.
54
Put the mail flag down.
55
Jump for another byte.
56
Connect two R31-JPs by null modem.
Connect all three wires!
Female connector on board.
Female connector on board.
It works if you can detect ASCII A at P1 on the
receiver board.
Write a Comment
User Comments (0)
About PowerShow.com