Getting Started with I²C Using MSSP on PIC18
■The approach in implementing the I²C communication protocol is different among the PIC18F device family of microcontrollers. While the PIC18-K40 and PIC18-Q10 product families have a Master Synchronous Serial Port (MSSP) peripheral, the PIC18-K42, PIC18-K83, PIC18-Q41, PIC18-Q43 and PIC18-Q84 product families have a dedicated I²C peripheral. The MSSP and I²C peripherals are serial interfaces useful for communicating with external hardware, such as sensors or microcontroller devices, but there are also differences between them.
■The MSSP peripheral can operate in one of two modes: Serial Peripheral Interface (SPI) and Inter-Integrated Circuit (I²C), having the advantage of implementing both communication protocols with the same hardware. For a detailed comparison between the MSSP and dedicated I²C peripherals, refer to: Master Synchronous Serial Port (MSSP) to the Stand-Alone I²C Module Migration.
■This technical brief provides information about the MSSP peripheral of the PIC18-K40 and PIC18-Q10 product families and intends to familiarize the user with the PIC® microcontrollers. The document covers the following use cases:
▲ Master Write Data: This example shows how the microcontroller configured in I²C Master mode writes data to an MCP23008 8-bit I²C I/O expander (slave device), addressed in 7-bit mode.
▲ Master Read/Write Data Using Interrupts: This example shows how the microcontroller configured in I²C Master mode writes to and reads data from an MCP23008 8-bit I²C I/O expander (slave device), addressed in 7-bit mode, using interrupts.
■For each use case, there are three different implementations, which have the same functionalities: one code generated with MPLAB® Code Configurator (MCC), one code generated using Foundation Services Library, and one bare metal code. The MCC generated code offers hardware abstraction layers that ease the use of the code across different devices from the same family. The Foundation Services generated code offers a driver-independent Application Programming Interface (API), and facilitates the portability of code across different platforms. The bare metal code is easier to follow, allowing a fast ramp-up on the use case associated code.
PIC18 、 PIC18F 、 PIC18-K40 、 PIC18-Q10 、 PIC18-K42 、 PIC18-K83 、 PIC18-Q41 、 PIC18-Q43 、 PIC18-Q84 、 MCP23008 |
|
|
|
Application note & Design Guide |
|
|
|
Please see the document for details |
|
|
|
|
|
|
|
English Chinese Chinese and English Japanese |
|
08/2020 |
|
Rev A |
|
TB3281;DS90003281A |
|
297 KB |
- +1 Like
- Add to Favorites
Recommend
All reproduced articles on this site are for the purpose of conveying more information and clearly indicate the source. If media or individuals who do not want to be reproduced can contact us, which will be deleted.