SlideShare a Scribd company logo
1 of 26
Starting with serial
Chapter Ten
10.3, 10.4, 10.5
Dr. Gheith Abandah 1
Outline
• 10.3 The 16F87XA Master Synchronous Serial
Port module in SPI mode
– Master and Slave Mode
– Program Example
• I2C Synch. Serial Communication.
Dr. Gheith Abandah 2
10.3 The 16F87XA Master Synchronous Serial
Port module in SPI mode
• The MSSP module is designed for synchronous
communication and can be configured as
– a simple synchronous port (called SPI mode) , or
– as an I2C port (Inter-Integrated Circuit).
• It has three SFRs dedicated to it, SSPCON1, SSPCON2 and
SSPSTAT, which can be found in the register file map diagram
of Figure 7.6.
• It also has a register for data transfer, SSPBUF, and is the
source of an interrupt, as seen in Figure 7.10.
• In this section we look at the module in SPI mode.
Dr. Gheith Abandah 3
Port Overview
• Figure 10.7 on next slide shows the MSSP configured as an
SPI port.
• It can be configured as master or slave, with a variety of clock
speeds if master.
• At the heart of the serial port is the shift register SSPSR. When clocked, it
transfers serial data to pin SDO (if the output buffer gate is enabled) and
transfers serial data in from pin SDI.
• If the port is set up as a slave, it will receive the clock from the system
master through pin SCK.
• If the port is set up as master, it will generate the clock, which now
outputs through the SCK pin. This clock is derived either from the internal
clock oscillator, or from Timer 2.
Dr. Gheith Abandah 4
Port Overview
• An important enhancement to our earlier simple serial port is
the addition of the buffer register SSPBUF.
• This holds a data byte on its way to or from the shift register,
and is actually the addressable register that the program
writes to or reads from.
• This makes the serial port much more flexible in use.
Dr. Gheith Abandah 5
The Master Synchronous Serial Port block diagram, in Serial
Peripheral interface
Dr. Gheith Abandah 6
Port Configuration
• The two SFRs that control the action of the port in
SPI mode are SSPCON1 and SSPSTAT.
• Their use differs somewhat between the SPI and I2C
modes.
• They are shown, when used in SPI mode, in Figures
10.8 and 10.9 respectively.
• In them there are bits to do the following:
– Enable and configure the port.
– Sett clock rate and clock characteristics.
– Manage data transfer and buffering.
Dr. Gheith Abandah 7
Dr. Gheith Abandah 8
Dr. Gheith Abandah 9
Port Configuration Cont.
• The port is enabled with bit 5 (SSPEN) of SSPCON1, and its
operating mode selected with the lower four bits of the same
register. It can be seen that these bits determine whether the port
is to work as master or slave.
• If in Master mode, four clock sources are available. As can be seen,
these are either the clock oscillator signal divided by 4, 16 or 64, or
the Timer 2 output
• If in Slave mode, the Slave Select input pin SS can be enabled,
through the four lower bits of SSPCON1. In this case, an external SS
signal can control the tristate buffer that drives the SDO pin and the
clock to the shift register.
– The SS input then effectively enables the serial port action and the
port can be used in a multi-node configuration
Dr. Gheith Abandah 10
Managing Data Transfer
• If the port is set as Master, a write to the buffer register
SSPBUF automatically starts a transfer, clocking out whatever
data has been loaded into SSPBUF and clocking in whatever
data is present at the SDI pin.
• On completion of eight clock cycles, the interrupt flag SSPIF is
set and data in the shift register SSPSR is automatically
transferred to the buffer SSPBUF.
• The SSPIF flag can be used as an interrupt to alert the CPU
that the transfer is complete.
• If there is a write to SSPBUF before the previous word has
been completely sent, then the write collision bit WCOL is set.
Dr. Gheith Abandah 11
Managing Data Transfer
• If it is set as Slave, then, when the SCK input starts switching,
the port clocks data into the SSPSR shift register through the
SDI pin. At the same time, data is clocked out of it from the
other end through the SDO pin. It is, of course, up to the
system designer to ensure that valid data is ready in the
SSPSR register and/or is available at the SDI input, according
to the requirement.
• When eight cycles are complete, the interrupt flag SSPIF is set
and, again, data in SSPSR is automatically transferred to the
buffer SSPBUF.
• If the previous byte has not been read from SSPBUF, then the
SSPOV bit is set, indicating a receive overflow.
Dr. Gheith Abandah 12
10.4 A simple Serial Peripheral Interface example
• The program enables the Derbot microcontroller SPI
by writing to SSPCON1 (for reasons of backward
compatibility the Assembler Include File calls this
SSPCON) and sets it up as a master, with clock
frequency Fosc/16. Clock control bits SMP and CKE
are both set to zero here.
• Clock and data output pins are set up as outputs via
TRISC.
• The program then transmits two bytes in turn
repeatedly on the serial link, with a 40 ms delay in
between.
Dr. Gheith Abandah 13
Dr. Gheith Abandah 14
Enhancing synchronous serial and the Inter-Integrated Circuit bus
• The Inter-Integrated Circuit (I2C) protocol was developed by Philips to
provide a serial communication standard to overcome some of the
shortcomings of Microwire or SPI.
• As its name suggests, it is meant to provide communication between ICs
within a single system.
• It is intended to be flexible and tolerant of different technologies and
speeds.
• Main Inter-Integrated Circuit features
• I2C is based on a master–slave relationship between nodes.
• The master controls all bus usage.
– Standard mode (with bit rate up to 100 kbps),
– Fast-mode (with bit rate to 400 kbps),
– Fast-mode Plus (with bit rate to 1 Mbps) and
– High-speed mode (with maximum bit rate of 3.4 Mbps).
Dr. Gheith Abandah 15
I2C
• The I2C bus uses only two lines for all interconnection, called
SDA (serial data) and SCL (serial clock).
• The output of each node connects to the bus using an Open
Drain or Open Collector output
• while the node input is through a standard logic buffer.
• The two interconnect lines each have a pull-up resistor.
• Both lines are bi-directional, but the SCL clock signal is always
generated by the current master.
• When no node is accessing the bus the Open Drain outputs
are all inactive and the lines idle at Logic 1.
Dr. Gheith Abandah 16
Dr. Gheith Abandah 17
I2C Signal Chsts.
• The I2C protocol follows a very clear format for data transfer, as
shown in Figure 10.13.
• It is initiated by a Start condition, in which the SDA line is taken
low, while the SCL line stays high.
• It is terminated by a Stop condition, in which the SDA line goes
high while the clock is held high.
• The Start and Stop conditions are asserted by the current master,
as is the clock.
• Between the Start and the Stop, data is transferred in bytes.
• During this time, the SDA value can only change when SCL is low;
data must remain stable when the clock line is high. This allows
data transfer and Start or Stop to be distinguished.
• The first byte of any transfer contains address information.
• The standard allows for either a 7-bit address, within a single
byte, or a 10-bit address spread across two bytes.
Dr. Gheith Abandah 18
Dr. Gheith Abandah 19
The Master Synchronous Serial Port configured for Inter-
Integrated Circuit
• In this case the SCL line is shared with bit 3 of Port C
and SDA with bit 4 of Port C.
• In I2C mode the port is significantly more complex
than when in SPI mode, and care needs to be taken
to understand it.
• The first indication of the increased complexity is
the whole extra control register, SSPCON2, needed
for I2Cmode.
Dr. Gheith Abandah 20
The MSSP Inter-Integrated Circuit registers and their
preliminary use
Dr. Gheith Abandah 21
Dr. Gheith Abandah 22
Dr. Gheith Abandah 23
Dr. Gheith Abandah 24
Dr. Gheith Abandah 25
Ex p 305
• Program Example 10.2 runs on the Derbot AGVand applies the I2C port as a
master. The key SFR settings are Port C (where I2C port bits must be set as inputs),
SSPADD (which determines the clock frequency) and SSPCON1 (which determines
the overall setting).
• Equation (10.1) is used to determine the value for SSPADD. The detail of the
SSPCON1 setting should be explored by comparing it with the register details in
Figure 10.14.
• All major I2C actions in the program are undertaken with the use of subroutines
and it is instructive to look at these.
• The program starts, from comment ;send opening string, by transmitting the
character message ‘Derbot’ to the hand controller.
• This is done in a single multiple-byte message. First the address is sent, using
subroutine I2C send add.
Dr. Gheith Abandah 26

More Related Content

Similar to 10_2Starting with serial_II.ppt

Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Aarav Soni
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolAditya Porwal
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacingRAMPRAKASHT1
 
spi-180501092933-converted.pptx
spi-180501092933-converted.pptxspi-180501092933-converted.pptx
spi-180501092933-converted.pptxsauryakumar3
 
Unit II Study of Onchip Peripherals
Unit II Study of Onchip PeripheralsUnit II Study of Onchip Peripherals
Unit II Study of Onchip PeripheralsDr. Pankaj Zope
 
Spartan-II FPGA (xc2s30)
Spartan-II FPGA (xc2s30)Spartan-II FPGA (xc2s30)
Spartan-II FPGA (xc2s30)A B Shinde
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsMohamed Abdallah
 
AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL
AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDLAREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL
AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDLIAEME Publication
 
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080Vivek Venugopal
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03Premier Farnell
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLJay Baxi
 
100 MHz High Speed SPI Master: Design, Implementation and Study on Limitation...
100 MHz High Speed SPI Master: Design, Implementation and Study on Limitation...100 MHz High Speed SPI Master: Design, Implementation and Study on Limitation...
100 MHz High Speed SPI Master: Design, Implementation and Study on Limitation...rahulmonikasharma
 
SOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsSOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsA B Shinde
 
PIC16F877A C Programming.ppt
PIC16F877A C Programming.pptPIC16F877A C Programming.ppt
PIC16F877A C Programming.pptIlaiyarajaS1
 

Similar to 10_2Starting with serial_II.ppt (20)

Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Spi in arm7(lpc2148)
Spi in arm7(lpc2148)
 
I2c buses
I2c busesI2c buses
I2c buses
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System Protocol
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
 
SPI Protocol in LPC2148
SPI  Protocol in LPC2148SPI  Protocol in LPC2148
SPI Protocol in LPC2148
 
Lpc2148 i2c
Lpc2148 i2cLpc2148 i2c
Lpc2148 i2c
 
spi-180501092933-converted.pptx
spi-180501092933-converted.pptxspi-180501092933-converted.pptx
spi-180501092933-converted.pptx
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
Unit II Study of Onchip Peripherals
Unit II Study of Onchip PeripheralsUnit II Study of Onchip Peripherals
Unit II Study of Onchip Peripherals
 
Spartan-II FPGA (xc2s30)
Spartan-II FPGA (xc2s30)Spartan-II FPGA (xc2s30)
Spartan-II FPGA (xc2s30)
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication Protocols
 
AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL
AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDLAREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL
AREA OPTIMIZATION OF SPI MODULE USING VERILOG HDL
 
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
 
Peripheral 8245,16550&8237 dma controller
Peripheral 8245,16550&8237 dma controllerPeripheral 8245,16550&8237 dma controller
Peripheral 8245,16550&8237 dma controller
 
100 MHz High Speed SPI Master: Design, Implementation and Study on Limitation...
100 MHz High Speed SPI Master: Design, Implementation and Study on Limitation...100 MHz High Speed SPI Master: Design, Implementation and Study on Limitation...
100 MHz High Speed SPI Master: Design, Implementation and Study on Limitation...
 
SOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC ToolsSOC Peripheral Components & SOC Tools
SOC Peripheral Components & SOC Tools
 
PIC16F877A C Programming.ppt
PIC16F877A C Programming.pptPIC16F877A C Programming.ppt
PIC16F877A C Programming.ppt
 

Recently uploaded

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

10_2Starting with serial_II.ppt

  • 1. Starting with serial Chapter Ten 10.3, 10.4, 10.5 Dr. Gheith Abandah 1
  • 2. Outline • 10.3 The 16F87XA Master Synchronous Serial Port module in SPI mode – Master and Slave Mode – Program Example • I2C Synch. Serial Communication. Dr. Gheith Abandah 2
  • 3. 10.3 The 16F87XA Master Synchronous Serial Port module in SPI mode • The MSSP module is designed for synchronous communication and can be configured as – a simple synchronous port (called SPI mode) , or – as an I2C port (Inter-Integrated Circuit). • It has three SFRs dedicated to it, SSPCON1, SSPCON2 and SSPSTAT, which can be found in the register file map diagram of Figure 7.6. • It also has a register for data transfer, SSPBUF, and is the source of an interrupt, as seen in Figure 7.10. • In this section we look at the module in SPI mode. Dr. Gheith Abandah 3
  • 4. Port Overview • Figure 10.7 on next slide shows the MSSP configured as an SPI port. • It can be configured as master or slave, with a variety of clock speeds if master. • At the heart of the serial port is the shift register SSPSR. When clocked, it transfers serial data to pin SDO (if the output buffer gate is enabled) and transfers serial data in from pin SDI. • If the port is set up as a slave, it will receive the clock from the system master through pin SCK. • If the port is set up as master, it will generate the clock, which now outputs through the SCK pin. This clock is derived either from the internal clock oscillator, or from Timer 2. Dr. Gheith Abandah 4
  • 5. Port Overview • An important enhancement to our earlier simple serial port is the addition of the buffer register SSPBUF. • This holds a data byte on its way to or from the shift register, and is actually the addressable register that the program writes to or reads from. • This makes the serial port much more flexible in use. Dr. Gheith Abandah 5
  • 6. The Master Synchronous Serial Port block diagram, in Serial Peripheral interface Dr. Gheith Abandah 6
  • 7. Port Configuration • The two SFRs that control the action of the port in SPI mode are SSPCON1 and SSPSTAT. • Their use differs somewhat between the SPI and I2C modes. • They are shown, when used in SPI mode, in Figures 10.8 and 10.9 respectively. • In them there are bits to do the following: – Enable and configure the port. – Sett clock rate and clock characteristics. – Manage data transfer and buffering. Dr. Gheith Abandah 7
  • 10. Port Configuration Cont. • The port is enabled with bit 5 (SSPEN) of SSPCON1, and its operating mode selected with the lower four bits of the same register. It can be seen that these bits determine whether the port is to work as master or slave. • If in Master mode, four clock sources are available. As can be seen, these are either the clock oscillator signal divided by 4, 16 or 64, or the Timer 2 output • If in Slave mode, the Slave Select input pin SS can be enabled, through the four lower bits of SSPCON1. In this case, an external SS signal can control the tristate buffer that drives the SDO pin and the clock to the shift register. – The SS input then effectively enables the serial port action and the port can be used in a multi-node configuration Dr. Gheith Abandah 10
  • 11. Managing Data Transfer • If the port is set as Master, a write to the buffer register SSPBUF automatically starts a transfer, clocking out whatever data has been loaded into SSPBUF and clocking in whatever data is present at the SDI pin. • On completion of eight clock cycles, the interrupt flag SSPIF is set and data in the shift register SSPSR is automatically transferred to the buffer SSPBUF. • The SSPIF flag can be used as an interrupt to alert the CPU that the transfer is complete. • If there is a write to SSPBUF before the previous word has been completely sent, then the write collision bit WCOL is set. Dr. Gheith Abandah 11
  • 12. Managing Data Transfer • If it is set as Slave, then, when the SCK input starts switching, the port clocks data into the SSPSR shift register through the SDI pin. At the same time, data is clocked out of it from the other end through the SDO pin. It is, of course, up to the system designer to ensure that valid data is ready in the SSPSR register and/or is available at the SDI input, according to the requirement. • When eight cycles are complete, the interrupt flag SSPIF is set and, again, data in SSPSR is automatically transferred to the buffer SSPBUF. • If the previous byte has not been read from SSPBUF, then the SSPOV bit is set, indicating a receive overflow. Dr. Gheith Abandah 12
  • 13. 10.4 A simple Serial Peripheral Interface example • The program enables the Derbot microcontroller SPI by writing to SSPCON1 (for reasons of backward compatibility the Assembler Include File calls this SSPCON) and sets it up as a master, with clock frequency Fosc/16. Clock control bits SMP and CKE are both set to zero here. • Clock and data output pins are set up as outputs via TRISC. • The program then transmits two bytes in turn repeatedly on the serial link, with a 40 ms delay in between. Dr. Gheith Abandah 13
  • 15. Enhancing synchronous serial and the Inter-Integrated Circuit bus • The Inter-Integrated Circuit (I2C) protocol was developed by Philips to provide a serial communication standard to overcome some of the shortcomings of Microwire or SPI. • As its name suggests, it is meant to provide communication between ICs within a single system. • It is intended to be flexible and tolerant of different technologies and speeds. • Main Inter-Integrated Circuit features • I2C is based on a master–slave relationship between nodes. • The master controls all bus usage. – Standard mode (with bit rate up to 100 kbps), – Fast-mode (with bit rate to 400 kbps), – Fast-mode Plus (with bit rate to 1 Mbps) and – High-speed mode (with maximum bit rate of 3.4 Mbps). Dr. Gheith Abandah 15
  • 16. I2C • The I2C bus uses only two lines for all interconnection, called SDA (serial data) and SCL (serial clock). • The output of each node connects to the bus using an Open Drain or Open Collector output • while the node input is through a standard logic buffer. • The two interconnect lines each have a pull-up resistor. • Both lines are bi-directional, but the SCL clock signal is always generated by the current master. • When no node is accessing the bus the Open Drain outputs are all inactive and the lines idle at Logic 1. Dr. Gheith Abandah 16
  • 18. I2C Signal Chsts. • The I2C protocol follows a very clear format for data transfer, as shown in Figure 10.13. • It is initiated by a Start condition, in which the SDA line is taken low, while the SCL line stays high. • It is terminated by a Stop condition, in which the SDA line goes high while the clock is held high. • The Start and Stop conditions are asserted by the current master, as is the clock. • Between the Start and the Stop, data is transferred in bytes. • During this time, the SDA value can only change when SCL is low; data must remain stable when the clock line is high. This allows data transfer and Start or Stop to be distinguished. • The first byte of any transfer contains address information. • The standard allows for either a 7-bit address, within a single byte, or a 10-bit address spread across two bytes. Dr. Gheith Abandah 18
  • 20. The Master Synchronous Serial Port configured for Inter- Integrated Circuit • In this case the SCL line is shared with bit 3 of Port C and SDA with bit 4 of Port C. • In I2C mode the port is significantly more complex than when in SPI mode, and care needs to be taken to understand it. • The first indication of the increased complexity is the whole extra control register, SSPCON2, needed for I2Cmode. Dr. Gheith Abandah 20
  • 21. The MSSP Inter-Integrated Circuit registers and their preliminary use Dr. Gheith Abandah 21
  • 26. Ex p 305 • Program Example 10.2 runs on the Derbot AGVand applies the I2C port as a master. The key SFR settings are Port C (where I2C port bits must be set as inputs), SSPADD (which determines the clock frequency) and SSPCON1 (which determines the overall setting). • Equation (10.1) is used to determine the value for SSPADD. The detail of the SSPCON1 setting should be explored by comparing it with the register details in Figure 10.14. • All major I2C actions in the program are undertaken with the use of subroutines and it is instructive to look at these. • The program starts, from comment ;send opening string, by transmitting the character message ‘Derbot’ to the hand controller. • This is done in a single multiple-byte message. First the address is sent, using subroutine I2C send add. Dr. Gheith Abandah 26