Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
21 views30 pages

Lecture 4

The document discusses interfacing microcontrollers with external signals, focusing on the transformation of variable values into voltages and the use of digital and analog inputs to measure and control physical phenomena. It details various communication interfaces, including onboard (I2C, SPI, UART) and external (wired and wireless) communication methods, along with their functionalities. Additionally, it covers specific protocols like USB and RS-232, and provides examples of microcontroller boards used for programming and interfacing.

Uploaded by

sigma.elev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views30 pages

Lecture 4

The document discusses interfacing microcontrollers with external signals, focusing on the transformation of variable values into voltages and the use of digital and analog inputs to measure and control physical phenomena. It details various communication interfaces, including onboard (I2C, SPI, UART) and external (wired and wireless) communication methods, along with their functionalities. Additionally, it covers specific protocols like USB and RS-232, and provides examples of microcontroller boards used for programming and interfacing.

Uploaded by

sigma.elev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Lec4: Interfacing

1
+ 2

Interfacing
n Connecting the computation capabilities of a microcontroller
to external signals
n Transforming variable values into voltages and vice-versa
n Digital and analog
n Issues
n How many signals can be controlled?
n How can digital and/or analog inputs be used to measure
different physical phenomena?
n How can digital and/or analog inputs be used to control
different physical phenomena?
+ 3

Controlling and reacting to the environment

n Tocontrol or react to the environment we need to interface


the microcontroller to peripheral devices
n Microcontroller may contain specialized interfaces to sensors and
actuators
n Things we want to measure or control
n light, temperature, sound, pressure, velocity, position
n Sensors
n e.g., switches, photoresistors, accelerometers, compass, sonar
n Actuators
n e.g., motors, relays, LEDs, sonar, displays, buzzers
+ 4

Communication Interface

nCommunication interface is essential for communicating with


various subsystems of the embedded system and with the
external world

1. Device/board level communication interface (Onboard Communication Interface)

2. Product level communication interface (External Communication Interface)


+ Onboard Communication Interface
5

n The communication channel which interconnects the various


components within an embedded product is referred as onboard
communication interface
n Serial interfaces
n I2 C (Inter Integrated Circuit) Bus
n SPI (Serial Peripheral Interface) Bus
n UART (Universal Asynchronous Receiver Transmitter)
n 1-Wires Interface

n Parallel bus interface


+ 6

External Communication Interface

n is responsible for data transfer between the embedded system and


other devices or modules. The external communication interface
can be either wired media or wireless media and it can be a serial
or parallel interface.
n Examples for wireless communication interface: Infrared (IR), Bluetooth
(BT), Wireless AN (Wi-Fi), Radio Frequency waves (RF), GPRS etc.
n Examples for wired interfaces: RS-232C/RS-422/RS 485, USB, Ethernet
(TCP-IP), IEEE1394 port, Parallel port etc.
+ 7

Inter-Integrated Circuit Bus (I2C)

n Modular connections on a printed circuit board

n Multi-point connections (needs addressing)

n Synchronous transfer (but adapts to slowest


device)

n Similar to Controller Area Network (CAN) protocol


used in automotive applications

n Similar to TWI (Two-Wire Interface) on ATmegas


+ 8

Serial data format


n SDA going low while SCL high signals start of data

n SDA going high while SCL high signals end of data

n SDA can change when SCL low

n SCL high (after start and before end) signals that a data bit can be read
+ 9

Byte transfer
n Byte followed by a 1 bit acknowledge from receiver

n Open-collector wires
n sender allows SDA to rise
n receiver pulls low to acknowledge after 8 bits

n Multi-byte transfers
n first byte contains address of receiver
n all devices check address to determine if following data is for them
n second byte usually contains address of sender
+ 10

Clock synchronization
n Synchronous data transfer with variable speed devices
n go as fast as the slowest device involved in transfer

n Each device looks at the SCL line as an input as well as driving it


n if clock stays low even when being driven high then another device needs more time, so wait for it to
finish before continuing
n rising clock edges are synchronized
+ 11

Inter-Integrated Circuit Bus (I2C)

n Supports data transfers from 0 to 400KHz


n Philips (and others) provide many devices
n microcontrollers with built-in interface
n A/D and D/A converters
n parallel I/O ports
n memory modules
n LCD drivers
n real-time clock/calendars
n DTMF decoders
n frequency synthesizers
n video/audio processors
+ 12

Serial Peripheral Interface (SPI)

n SPIis used to send data between


Microcontrollers and small
peripherals such as shift registers,
sensors, and SD cards.

n 8-bits
transferred in each direction
every time

n Master generates clock

n Shift
enable used to select one of
many slaves
+ 13

Data Payload on SPI


n Data is exchanged between master and slave
n Master always initiates
n May need to poll slave (or interrupt-driven)
n Decide on how many bytes of data have to move in each direction
n Transfer the maximum for both directions
n One side may get more than it needs
n Decide on format of bytes in packet
n Starting byte and/or ending byte?
n Can they be distinguished from data in payload?
n Length information or fixed size?
n SPI buffer
n Write into buffer, specify length, master sends it out, gets data
n New data arrives at slave, slave interrupted, provides data to go to master, reads data from
master in buffer
+ 14

I2C v/s SPI


+ 15

Universal Serial Bus


n Connecting peripherals to PCs
n Ease-of-use
n Low-cost
n Up to 127 devices (optionally powered through bus)
n Transfer rates up to 480 Mb/s (USB 2.0)
n Variable speeds and packet sizes
n Full support for real-time data for voice, audio, and video
n Protocol flexibility for mixed-mode isochronous data transfers and asynchronous
messaging
n PC manages bus and allocates slots (host controller)
n Can have multiple host controllers on one PC
n Support more devices than 127
+ 16

USB Peripherals
+ 17

USB Data Transfer

n Data transfer speeds


n Low is <0.8v, high is >2.0v differential
n 480Mb/sec, 12Mb/sec, 1.5Mb/sec
n Data is NRZI encoded (data and clock on one wire)
n SYNC at beginning of every packet
+ 18

USB Packet Format


n Sync + PID + data + CRC

n Basic data packet


n Sync: 8 bits (00000001)
n PID: 8 bits (packet id – type)
n Data: 8-8192 bits (1K bytes)
n CRC: 16 bits (cyclic redundancy check sum)

n Other data packets vary in size


n May be as short as only 8 bits of PID
+ 19

RS-232 (standard serial line)

n Point-to-point, full-duplex
n Synchronous or asynchronous
n Flow control
n Variable baud (bit) rates
n Cheap connections (low-quality and few wires)
n Variations: parity bit; 1, 1.5, or 2 stop bits
+ 20

RS-232 wires
+ 21

Transfer modes

nn Synchronous
n clock signal wire is used by both receiver and sender to sample data
nn Asynchronous
n no clock signal in common
n data must be oversampled (16x is typical) to find bit boundaries
nn Flow control
n handshaking signals to control rate of transfer
+ 22

Upstream - BL0086 - 8-Bit AVR Programmer

q The board comes complete with a


powerful ATMEGA328P
microcontroller.
q The board presents all port pins
collected together as E-blocks 2
sockets.
q The board takes power from an
external power supply or from the
micro USB port.
+ 23

BL0086 –Block diagram


+ 24

BL0086 Layout
+ 25
+ 26

BL0061 - ST ARM Programmer

• The board comes complete with


a powerful series 4 ARM
microcontroller.
• The board presents all port pins
collected together as E-blocks 2
sockets.
• The board takes power from an
external power supply or from
the micro USB port.
27
28
+ 29
+ 30

lab2

You might also like