MICROCONTROLLER AND INTERFACING
Download
Report
Transcript MICROCONTROLLER AND INTERFACING
MICROCONTROLLER AND INTERFACING
Presented by: Shefali Jethva (140803111008)
Shivali Panchal (140803111009)
Komal Soni
(140803111010)
Roll no. :- 14EC308
14EC309
14EC310
Discipline: EC 5th Sem.
Guided by: Prof. Isha Gautam
prof. Satish Bhati
CONTENTS
• I2C PROTOCOL
• SPI PROTOCOL AND DISPLAY INTERFACING
• PWM PROGRAMMING AND DC MOTOR CONTROL
What is I2C?
Shorthand for an “ Inter-Integrated Circuit” bus.
Developed by Philips Semiconductor for TV sets in the
1980’s.
I2c devices includes EPROMs, thermal Sensors & real
time clock.
Used as a control interface to signal processing devices
that have separate data interface.
Eg. Rf tuner, video decoder & encoder & audio
processor.
Limited to about 10 feet for moderate speed.
I2C PROTOCOL:
Master sends start condition(s) & controls the clock signal.
Controls the clock signal.
Master sends a unique 7-bits slave devices address.
Master sends read/write bit (R/W)-0-slave receive,1-slave transmit.
Slave with matching 7-bit device address always sends acknowledge bit(ACK).
Transmitter (slave or master) transmit 1 byte of the data.
I2C FEATURE:
“ Clock Stretching”-When the receive needs more time to process a
bit, it can pull SCl low to keep it from going high a bit longer. This
technique is called Clock stretching. On SDL low, the transmitter can
send its next data value, but this slave is ready to release SCL to go
high.
“General Call” broadcast- address every device on the bus.
10-bit extended addressing for new designs 7-bit address a
exhausted.
SPI Configuration:
• Primarily used for serial
communication between a
host processor and
peripherals.
• Can also connect 2
processors via SPI
• SPI works in a master slave
configuration with the
master being the host
microcontroller for example
and the slave being the
peripheral
SPI Operation:
• For SPI, there are Serial Clocks (SCLK), Chip Select lines (CS),
Serial Data In (SDI) and Serial Data Out( SDO)
• There is only one master, there number of slaves depends on
the number of chip select lines of the master.
• Synchronous operation, latch on rising or falling edge of clock,
SDI on rising edge, SDO on falling edge
• Operates in 1 to 2 MHz range.
• Master sends out clocks and chip selects.
Advantages of SPI:
• It’s faster than asynchronous serial
• The receive hardware can be a simple shift register
• It supports multiple slaves
• Disadvantages of SPI:
• It requires more signal lines than other communications methods
• The communications must be well-defined in advance
• The master must control all communications
• It usually requires separate SS lines to each slave, which can be problematic
if numerous slaves are needed.
PWM PROGRAMMING AND
DC MOTOR CONTROL
WHAT IS PWM ?
•
PWM is a way of digitally encoding analog signal levels.
•
Through the use of high-resolution counters, the duty cycle of
a square wave is modulated to encode a specific analog signal
level.
• The PWM signal is digital because, at any given instant of
time, the full DC supply is either fully on or fully off.
• The voltage or current source is supplied to the analog load by
means of a repeating series of on and off pulses.
INTERFACING OF AVR AND DC MOTOR
PROGRAM: 1
A switch is connected to PA 7. perform following:
(a) PA7=0, motor moves clock wise
(b) PA7=1, motor moves anti-clock wise
.INCLUDE "M32DEF.INC"
SBI DDRC,0
SBI DDRC,1
SBI DDRC,2
SBI DDRC,3
CBI DDRA,7
CLOCKWISE: SBIS PINA,7
RJMP CLOCKWISE
CBI DDRC,1
CBI DDRC,2
SBI DDRC,0
SBI DDRC,3
JMP MONITOR
// MAKE PC0 AS AN OUTPUT (SW-1)
// MAKE PC1 AS AN OUTPUT (SW-2)
// MAKE PC2 AS AN OUTPUT (SW-3)
// MAKE PC3 AS AN OUTPUT (SW-4)
//
//
//
//
// MAKE PA7 AS AN INPUT
// SKIP NEXT IF PA7 IS SET
// IF PA7=0 GO TO CLOCKWISE
SW 2=0
SW 3=0
SW 1=1
SW 4=1
ANTI-CLOCKWISE: CBI DDRC,0
CBI DDRC,3
SBI DDRC,1
SBI DDRC,2
JMP MONITOR
• OUTPUT:
//
//
//
//
SW 1=0
SW 4=0
SW 2=1
SW 3=1