I2C using (MSSP)


Posted on May 20, 2012

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.


I2C using (MSSP)
Click here to download the full size of the above Circuit.

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.




Leave Comment

characters left:

New Circuits

.

 


Popular Circuits

Simple FM transmitter circuit
filtering noisy power signal
TV Remote Control Jammer
VFO/BUFFER circuit
AN7522 circuit diagram
8255 uses 64 input expansion interface circuit



Top