100% found this document useful (2 votes)
557 views

Serial Communication Bus-Interface (Unit3)

The document discusses various serial communication interfaces used with microcontrollers, including I2C, SPI, and UART. It describes the basic protocols and features of these serial buses, how they are used to transfer data synchronously and asynchronously, and their applications in communicating with external devices and between microcontrollers. It also covers related concepts like baud rate, data formatting, and interrupt-driven transmission and reception.

Uploaded by

Surekha Pitta
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
557 views

Serial Communication Bus-Interface (Unit3)

The document discusses various serial communication interfaces used with microcontrollers, including I2C, SPI, and UART. It describes the basic protocols and features of these serial buses, how they are used to transfer data synchronously and asynchronously, and their applications in communicating with external devices and between microcontrollers. It also covers related concepts like baud rate, data formatting, and interrupt-driven transmission and reception.

Uploaded by

Surekha Pitta
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 44

SERIAL COMMUNICATION and BUS

Interface
Serial Communication standards
Serial Data Transfer scheme
On-board communication Interfaces-I2C Bus,SPI Bus,UART
External Communication Interfaces-RS-232,USB

1
DATA COMMUNICATION
• The 8051 microcontroller is a parallel device that transfers
eight bits of data simultaneously over eight data lines to
parallel I/O devices.
• The parallel I/O devices are printer, D/A converter and
stepper motor.
• However, in many situations, parallel data transfer is
impractical. For example, parallel data transfer over a long
distance is very expensive.
• Hence, serial data communication is widely used in long
distance data communication, and in this mode, one bit of
information, at a time is transferred over a single line.

8051 Microcontroller: Hardware, Software & Applications 2


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
SERIAL AND PARALLEL DATA TRANSFER

8051 Microcontroller: Hardware, Software & Applications 3


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
SERIAL DATA COMMUNICATION
• Simplex In simplex transmission, the line is dedicated for
transmission. The transmitter sends and the receiver
receives the data..
• Half duplex In half duplex, the communication link can be
used for either transmission or reception. Data is
transmitted in only one direction at a time.
• Full duplex If the data is transmitted in both ways at the
same time, it is a full duplex, i.e. transmission and
reception can proceed simultaneously. This
communication link requires two wires for data, one for
transmission and one for reception.

8051 Microcontroller: Hardware, Software & Applications 4


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
SIMPLEX, HALF DUPLEX
AND FULL DUPLEX DATA TRANSFER

8051 Microcontroller: Hardware, Software & Applications 5


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
TYPES OF SERIAL DATA COMMUNICATION

Synchronous Serial Data Communication In synchronous serial data


communication, transmitter and receiver are synchronized.
• It uses a common clock signal to synchronize the receiver and the
transmitter.The transmission of data; first the sync character and then, the
data is transmitted.
• This format is generally used for high-speed transmission.
Asynchronous Serial Data Communication In asynchronous serial data
communication, different clock sources are used for transmitter and
receiver.
• In this mode, data is transmitted with start and stop bits.
• Transmission begins with start bit, followed by data and then stop bit.
• The transmission of 10 bit in the asynchronous format: one start bit, eight
data bit and one stop bit. For error checking purpose, parity bit is included
just prior to stop bit.

8051 Microcontroller: Hardware, Software & Applications 6


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
SYNCHRONOUS TRANSMISSION FORMAT

8051 Microcontroller: Hardware, Software & Applications 7


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
ASYNCHRONOUS TRANSMISSION FORMAT

8051 Microcontroller: Hardware, Software & Applications 8


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
BAUD RATE

• The rate at which the bits are transmitted (bits/second) is


called baud or transfer rate.
• The baud rate is the reciprocal of the time to send 1 bit. In
asynchronous transmission, baud rate is not equal to number
of bits per second.
• This is because, each byte is preceded by a start bit and
followed by parity and stop bit.
• For example, in synchronous transmission, if data is
transmitted with 9600 baud, it means that 9600 bits are
transmitted in one second.
• For one bit, transmission time = 1 second/9600 = 0.104 ms.

8051 Microcontroller: Hardware, Software & Applications 9


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
On-Board Communication Interfaces

8051 Microcontroller: Hardware, Software & Applications 10


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
IC
2
Inter-Integrated Circuit
• Developed and patented by Philips for
connecting low speed peripherals to a
motherboard, embedded system or cell phone
• Multi-master, two wire bus , up to 100 kbits/sec
– One data line (SDA)
– One clock line (SCL)
– Master controls clock for slaves
– Each connected slave has a unique 7-bit address
Protocol
• Transfers are byte oriented, msb first
• Start: SDA goes low while SCL is high
• Master sends address of slave (7-bits) on next 7
clocks
• Master sends read/write request bit
– 0-write to slave
– 1-read from slave
• Slave ACKs by pulling SDA low on next clock
• Data transfers now commence
Terminology
• Transmitter – The device sending data to the bus
• Receiver – Device receiving data from the bus
• Master – device initiating a transfer, generates to clock and
terminates a transfer
• Slave – Device addressed by the master
• Multi-master – more than one master can attempt to control the
bus
• Arbitration – procedure to insure that only one master has
control of ther bus at any instant
• Synchronization – procedure to sync then clocks of two or more
devices
Master-to-Slave Data Transfer
• Clock is controlled by master
• Data is written to slave on next 8 clock pulses
• Data receipt is ACKed by slave on 9th pulse by
pulling SDA low
• When slave releases SDA master can send next byte
• Master will eventually set a Stop condition by
making a low to high transition on SDA with SCL is
high
I2C Extensions
• 10 bit addressing (up to 1024 addresses)
• Fast mode – up to 400 kbits/sec
• High-Speed – up to 3.4 Mbits/sec
SPI Bus

17
Serial Peripheral Interface (SPI)

SPI = Simple, 3 wire, full duplex, synchronous serial data transfer

Interfaces to many devices, even many non-SPI peripherals

Can be a master or slave interface

4 interface pins:
-MOSI master out slave in
-MISO master in slave out
-SCK serial clock
-SS_n slave select

3 registers:
-SPCR control register
-SPSR status register
-SPDR data register
Serial Peripheral Interface (SPI)

master SPI device slave SPI device

Data is shifted out of the master's (mega128) MOSI pin and in its MISO pin

Data transfer is initiated by simply writing data to the SPI data register.

All data movement is coordinated by SCK.

Slave select may or may not be used depending on interfacing device.

To get input data only you send “junk” data to SPDR to start the clock.
Serial Peripheral Interface
• Allows transfer of information, 8 bits at a time, between microcontroller and
any number of peripherals
• Read and Write operations happen simultaneously
• Using chip selects allows lots of peripherals to be connected to a single SPI
bus at the same time
• Has no start/stop bit overhead
• High data rates: 250Kbit to 2Mbit/sec
• Common uses:
– Inter-Processor Network
– Sending MP3 data to MP3 decoders
– Interfacing to external serial RAM/EEPROM/FLASH
– Interfacing to serial graphic LCDs
– Compatible with thousands of chips with SPI, Microwire, I2S, and other serial
interfaces
SPI and Microcontrollers

• Motorola 68HC12 Has SPI built in


hardware. Easy to integrate.

• Intel 8051 Depending on Models, Most


Cygnal products have I2C and some have
SPI also built in hardware for easy
integration.
UART
• The UART, or Universal Asynchronous Receiver Transmitter,
provides hardware support for a serial port on AVR processors
– Signaling is compatible with PC/Mac/Unix serial (RS-232C)
• The UART provides:
– Parallel-to-Serial and Serial-to-Parallel conversion
– Start and Stop Bit framing
– Parity Generation
– Baud-Rate Generation (2400-115.2kbps at 3.686 or 7.37MHz)
– Interrupts
• Transmit Complete
• Transmit Data Register Empty
• Receive Complete

October 4, 2002 #22


Serial Specification (RS-232C)
• Data
– Start bit
– 6,7,8,9 data bits
– Parity bit optional (E,O,M,S,N)
– Stop bit
• Voltages
– Processor outputs 0/5V logic-level signal
– RS-232C uses +12V/-12V signal
5V – – Level-converter IC provided on STK500 (MAX202)
0V –
UART Registers
• UDR (UART Data Register)
– Write bytes to transmit
– Read received bytes
• USR (UART Status Register)
– Rx/Tx complete signal bits
– Framing error, overflow signal bits
• UCR (UART Control Register)
– Interrupt enable bits
– Rx/Tx enable bits
– Data format control bits
• UBRR (UART Baud Rate Register)
– Baud rate generator division ratio
UART Transmitting
• Send a byte by writing to UDR register
– TXC bit in USR is set when the final bit has
finished transmitting
– Tx Complete interrupt triggered if enabled in
the UCR
– Must wait for current byte to finish transmitting
before sending the next one
UART Receiving
• How do I know a byte has arrived?
– Watch the RXC bit in USR
– Use the Rx Complete interrupt and write an ISR
• Read received bytes from the UDR
– UDR is double-buffered, but be sure to read it in time
UART Baud Rate
• Set by UBRR
• Varies with fCK

October 4, 2002 #27Stanford


Universit
STK500 UART Connection
• UART is actually a generic term that
includes a large number of different
devices/standards.
– RS-232 is a standard that specifies
• “electrical characteristics and timing of signals, the
meaning of signals, and the physical size and pin out
of connectors.

29
RS232
• RS232 is the most widely used serial I/O interfacing
standard. The RS232 standard was published by the
Electronic Industry Association (EIA) in 1960.
• The COM1 and COM2 ports in IBMPC are RS232
compatible ports. In RS232, 1 is represented by –3 to –25
V and 0 is represented by +3 to +25 V.
• In a microcontroller, serial TXD and RXD lines are TTL
compatible i.e. 1 and 0 are represented by +5 V and 0 V.

8051 Microcontroller: Hardware, Software & Applications 30


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
RS232
• For this reason, in order to connect a microcontroller to
RS232 bus, voltage converters are used.
• MAX 232 IC is commonly used to convert the TTL logic
levels to the RS232 voltage levels.
• The significance of the 232 is that 2 is transmission line, 3
is receiving line, and 7 (2+3+2) is signal ground line.
• In RS232, ground line is common to the transmitter and
receiver, and they are usable up to one meter without any
shield.

8051 Microcontroller: Hardware, Software & Applications 31


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
RS232 PLUG CONNECTORS
• The communication link consists of Data
Terminal Equipment (DTE) and an
associated modem (DCE) at each end.
• The function of modem is to process digital
information received from the computer
into a form suitable for analog transmission.
• Also, it receives analog signal and
processes it into digital information

8051 Microcontroller: Hardware, Software & Applications 32


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
DATA COMMUNICATION SYSTEM

8051 Microcontroller: Hardware, Software & Applications 33


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
DB-25 AND DB-9 CONNECTORS

8051 Microcontroller: Hardware, Software & Applications 34


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
INTERFACE OF TWO MICROCONTROLLERS
WITH MINIMUM SIGNALS

8051 Microcontroller: Hardware, Software & Applications 35


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
The Connector
The pins abbreviations
are (numbers in
parentheses are the
25D pin numbers.
1. CD (8)
2. RD (Rx) (3)
3. TD (Tx) (2)
4. DTR (20)
5. SG (Ground) (7)
6. DSR (6)
7. RTS (4)
8. CTS (5)
9. RI (22)
36
DESCRIPTION
• Transmitted Data Data Terminal Equipment (DTE)
transmits data through this pin.
• Received Data Data Terminal Equipment (DTE) receives
data through this pin.
• Signal Ground This circuit establishes a common ground
reference potential for all interface circuits.
• Data Terminal Ready (DTR) When Data Terminal
Equipment (DTE) is turned on, it sends active low signal
DTR and indicates that DTE is ready for communication.
If DTE is not ready for communication, then this signal is
not activated.

8051 Microcontroller: Hardware, Software & Applications 37


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
DESCRIPTION
• Data Set Ready (DSR) When modem is turned on, it sends an active low
signal DSR and indicates that it is ready for communication. that the
telephone is ringing and is used when DTE is in charge of answering the
phone.
• Request To Send (RTS) DTE asserts this signal to its associated DCE
(modem) when it has data to transmit. RTS is an active low output from
DTE and an input to the modem.
• Clear To Send (CTS) In response to RTS, the modem sends out signal
CTS to DTE and indicates that it is ready to receive the data.
• Data Carrier Detect (DCD) DCD is an output from the modem (DCE)
and an input to DTE. The modem asserts signal DCD to inform DTE
that a valid carrier has been detected.
• Ring Indicator (RI) RI is an output from the modem (DCE) and an input
to DTE. This signal indicates

8051 Microcontroller: Hardware, Software & Applications 38


Dr.V.Udayashankara & MallikarjunaSwamy M.S., Tata Mc Graw Hill, India
Introduction to the USB Protocol
• External Bus Standard.
• Allows connection of peripheral devices.
• Connects Devices such as keyboards, mice,
scanners, printers, joysticks, audio devices,
disks.
• Facilitates transfers of data at 480 (USB 2.0
only), 12 or 1.5 Mb/s (mega-bits/second).
• Developed by a Special Interest Group
including Intel, Microsoft, Compact, DEC, IBM,
Northern Telecom and NEC originally in 1994
39
USB 2.0
• A USB 2.0 requires a similar engineering
effort to USB 1.1
• Backwards and forwards compatible
– Old devices work with new hosts
– New devices work with old hosts
• The only difference is really the addition of
a 40x high-speed mode and the inclusion
of a more complicated external bus
interface
40
USB Speeds
• Low-Speed: 10 – 100 kb/s
• 1.5 Mb/s signaling bit rate
• Full-Speed: 500 kb/s – 10 Mb/s
• 12 Mb/s signaling bit rate
• High-Speed: 400 Mb/s
• 480 Mb/s signaling bit rate
• NRZI with bit stuffing used
• SYNC field present for every packet
41
USB
• Universal Serial Bus (USB) connects
between a computer and peripheral devices
– Created to replace various slow buses (parallel,
serial, and keyboard connections)
• USB 2.0: up to 480Mb/s (35 MB/s)
• USB 3.0: up to 6Gb/s (625 MB/s)
USB Device Basics
– A USB device can never start sending data without
first being asked by the host controller
– Single-master implementation
• Host polls various devices
• A device can request a fixed bandwidth (for audio and
video I/O)
– Universal Serial Bus is a misnomer…
• Actually a tree built out of point-to-point links
– Links are four-wire cables (ground, power, and two signal
wires)
USB Device Basics – The
Protocol
• USB protocol defines a set of standards that
any device can follow
– No need to write a driver for a device that is in
a predefined class and follows that standard,
– Predefined classes: storage devices, keyboards,
mice, joysticks, network devices, and modems
– No defined standard for video devices and
USB-to-serial devices
• A driver is needed for every device

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