Description: I2C are widely use for to communicate with external peripheral such as port expender, EEPROM, Real Time Clock etc. The Master Synchronous Serial Port (MSSP) module in PIC18 can be used to communicated with I2C peripheral. MSSP module can be configure to work as SPI and I2C. In this example the module will be configured as I2C to communicate with a port expender from Microchip MCP23017. The circuit below is built up on breadboard to test the MSSP function as an I2C module. More: The DIL switch on Port B is used to control the LED on Port A of the IO expender. INTB from the IC is connected to the INT2 pin of the PIC so that the PORTA output of the Port expender can be updated with the value from the DIL switch. The code function will be implemented using 2 interrupt, one at the high priority location for the External interrupt and the other for MSSP module at the low interrupt. MSSP module had to be configured as I2C master mode for this example. The code below shows the setting to initialize MSSP module. unction for sending and receiving data for I2C is created according to the required protocol to communicate with MCP23017. The code below shows the function i2cTransmit and i2cRecieve for receiving data and the interrupt routine for the handling of transmission/reception. The 2 function is used to load the data buffer for transmission and reception. The Interrupt function will pass the data accordingly to the MSSP module according to the protocol written in the datasheet of MCP23017.
The I2C (Inter-Integrated Circuit) protocol is a widely used communication interface for connecting microcontrollers to various external peripherals, such as port expanders, EEPROMs, and real-time clocks. In this application, the Master Synchronous Serial Port (MSSP) module of the PIC18 microcontroller is configured to operate in I2C mode to communicate with the MCP23017 port expander from Microchip Technology.
The circuit is implemented on a breadboard, allowing for easy testing and modification of the MSSP functionality as an I2C master. The DIL switch connected to Port B of the PIC18 is utilized to control the LEDs connected to Port A of the MCP23017. This setup enables the user to manipulate the state of the LEDs based on the input from the DIL switch.
The INTB pin of the MCP23017 is connected to the INT2 pin of the PIC18, facilitating an interrupt-driven approach to update the PORTA output of the MCP23017 based on the DIL switch's state. Two interrupts are employed in the code: a high-priority interrupt for handling external interrupts and a low-priority interrupt for managing the MSSP module's operations.
To initialize the MSSP module in I2C master mode, specific configuration settings must be applied. This includes setting the appropriate clock frequency and enabling the I2C functionality. The code snippet for initializing the MSSP module is crucial for ensuring proper communication with the MCP23017.
Functions for data transmission and reception, namely `i2cTransmit` and `i2cReceive`, are created according to the I2C protocol specifications outlined in the MCP23017 datasheet. These functions manage the loading of data buffers for sending and receiving data over the I2C bus. The interrupt service routine handles the transmission and reception processes, ensuring that data is passed to and from the MSSP module as per the defined protocol.
Overall, this circuit design exemplifies the integration of I2C communication with the PIC18 microcontroller, showcasing the use of interrupts and the MSSP module to effectively interface with the MCP23017 port expander for controlling multiple outputs based on user input.I2C are widely use for to communicate with external peripheral such as port expender, EEPROM, Real Time Clock etc. The Master Synchronous Serial Port (MSSP) module in PIC18 can be used to communicated with I2C peripheral.
MSSP module can be configure to work as SPI and I2C. In this example the module will be configured as I2C to communicate with a port expender from Microchip MCP23017. The circuit below is built up on breadboard to test the MSSP function as an I2C module. The DIL switch on Port B is used to control the LED on Port A of the IO expender. INTB from the IC is connected to the INT2 pin of the PIC so that the PORTA output of the Port expender can be updated with the value from the DIL switch. The code function will be implemented using 2 interrupt, one at the high priority location for the External interrupt and the other for MSSP module at the low interrupt.
MSSP module had to be configured as I2C master mode for this example. The code below shows the setting to initialize MSSP module. unction for sending and receiving data for I2C is created according to the required protocol to communicate with MCP23017. The code below shows the function i2cTransmit and i2cRecieve for receiving data and the interrupt routine for the handling of transmission/reception.
The 2 function is used to load the data buffer for transmission and reception. The Interrupt function will pass the data accordingly to the MSSP module according to the protocol written in the datasheet of MCP23017.
The I2C serial bus is a widely used two-wire bus for small-area networks. The I2C Clock and Data lines feature open collector (or drain) outputs for each device on the network, requiring only a single pull-up resistor. This architecture allows...
When the SDA (Serial Data) lines on both the left and right lines are high (logic level 1), the circuit remains in a quiescent state, and the optoisolators IC1 and IC2 are not activated.
In this circuit, the Serial Data...
This beginner's breadboard circuit simulates the action of throwing a dice. By pressing a button, the circuit generates a random output, lighting up one of six LEDs to represent the result of the throw.
The circuit utilizes a microcontroller or a...
This section of the I2C interfacing project focuses on constructing an acceleration sensor while also addressing two additional aspects: the advanced application of the PCF8591 chip (previously discussed in the context of the pressure sensor) and operating the bus at...
Learn to use the LCD display on the PIC 18 Explorer board with the SPI library. The SPI library will be utilized to easily display characters on the LCD. Additionally, the operation of I/O expanders will be explored.
The PIC 18...
The SCHAER+ programmer is a programmer for PIC18 family from a PC parallel port (LPT). It is derived from the SCHAER programmer I used to download my projects in PIC1684. The SCHAER+ programmer should be improved to use a USB...
Each integrated circuit (IC) on the I²C bus requires a unique address. Typically, these ICs can choose from a range of 2 to 8 possible addresses, enabling multiple chips of the same type to coexist on a single bus. The...
A cost-effective I2C bus-controlled stereo decoder, TDA9853H, is utilized for digital mediation in FM radio applications. It operates within a stereo decoding circuit, processing the baseband signal that has been encoded into stereo format. The chip interfaces with the stereo...
The board is relatively simple and is based on a PCF8574, which provides the output of a CD 4040 counter to the I2C bus. A DIP switch is included to select the PCF8574 address, along with some LEDs for power...
We use cookies to enhance your experience, analyze traffic, and (if you allow) serve personalized ads.
By clicking Accept All, you agree to our use of cookies.
Learn more