Chapter 11: Synchronous Serial IO
This chapter discusses synchronous serial IO as implemented on the PIC18. The Serial Peripheral Interface (SPI) and I 2C (Inter IC) bus protocols are covered, with sample interfaces to a digital potentiometer and serial EEPROMs.
11.1 LEARNING OBJECTIVES
After reading this chapter, you will be able to:
-
Compare and contrast synchronous serial IO on the PIC18 using the SPI and I 2C protocols.
-
Discuss the uses of digital potentiometers and serial EEPROMs in PIC18 applications.
-
Interface a PIC18 to a serial EEPROM using the SPI protocol.
-
Interface a PIC18 to a digital potentiometer using the SPI protocol.
-
Interface a PIC18 to a serial EEPROM using the I 2C protocol.
-
Use interrupt-driven double buffering to implement continuous data stream applications.
11.2 THE PIC18 AND SYNCHRONOUS SERIAL IO
In Chapter 9, "Asynchronous Serial IO," we discussed three methods for synchronizing a receiver to a serial data stream. The simplest method sends the clock as a separate signal, which is the mechanism used by the subsystems on the PIC18 that support synchronous serial IO. PIC18 synchronous serial IO options are summarized in Table 11.1. The USART subsystem was previously discussed in Chapter 9 for asynchronous IO; when used in synchronous mode the TX and RX pins are used for clock (CK) and data pins (DT), respectively.
Subsystem | Protocol | Classification | Pins(18F242) |
---|---|---|---|
USART | n/a | Half-duplex | RC6/TX/ CK (clock), RC7/RX/ DT (data) |
MSSP | SPI | Duplex | RC3/ SCK/SCL (clock), RC4/ SDI/SDA (data in),... |