This repository contains an example of Foundation Services generated source code for I2C as described in TB3281 - Getting Started with I2C Using MSSP on PIC18 document from Microchip.
The PIC18F47Q10 configured in I2C Host Mode using the MSSP1 peripheral and performing write operations. This example will use the client MCP23008, an I/O expander, addressed in 7-bit mode.
- TB3281 - Getting Started with I2C Using MSSP on PIC18
- PIC18-Q10 Product Family Page
- PIC18F47Q10 Data Sheet
- MCP23008 - 8-Bit I/O Expander with Serial Interface
- PIC18F47Q10 Code Examples on GitHub
- MPLAB® X IDE 5.30 or newer (microchip.com/mplab/mplab-x-ide)
- MPLAB® XC8 2.10 or newer (microchip.com/mplab/compilers)
- MPLAB® Code Configurator (MCC) 3.95.0 or newer (microchip.com/mplab/mplab-code-configurator)
- Foundation Services Library 0.2.0 or newer (microchip.com/mplab/mplab-code-configurator)
- Microchip PIC18F-Q Series Device Support 1.3.89 or newer (packs.download.microchip.com/)
- Curiosity Nano Base for Click Boards™ (AC164162)
- PIC18F47Q10 Curiosity Nano (DM182029)
- PICkit™ Serial I2C™ Demo Board (PKSERIAL-I2C1)
The PIC18F47Q10 Curiosity Nano Development Board is used as the test platform.
The following configurations must be made for this project:
- Clock
- Oscillator Select: HFINTOSC
- HF Internal Clock: 64 MHz
- Clock Divider: 1
- MSSP1
- Serial Protocol: I2C
- Mode: Host
- I2C Clock Frequency: 100000
- Watchdog Timer: disabled
- Low-voltage Programming: disabled
Pin | Configuration |
---|---|
RB1 (SCL1) | With Pull Up |
RB2 (SDA1) | With Pull Up |
-
Connect the board to the PC.
-
Open the pic18f47q10-cnano-i2c-read-write-int-bare.X project in MPLAB® X IDE.
-
Configure the project properties:
- Right click on the project and click Properties
- Select the device pack in the Packs tab
- Select the PIC18F47Q10 Curiosity Nano (click on the SN) in the Hardware Tool tab
- Select the compiler version in the Compiler Toolchain tab
- Click OK to save the changes
- Program the project to the board: right click on the project and click Make and Program Device
Demo:
This project is an illustration for a basic use case based around MSSP1.