Specifications

mikroElektronika | Free Online Book | PIC Microcontrollers | Chapter 6: Serial Communication Modules
In Short:
In order to establish serial communication in I²C mode, the following should be done:
Setting Module and Sending Address:
Value to determine baud rate should be written to the SSPADD register;
SlewRate control should be turned off by setting the SMP bit of the SSPSTAT register;
In order to select Master mode, binary value 1000 should be written to the SSPM3-SSPM0 bits of the SSPCON1
register;
The SEN bit of the SSPCON2 register should be set (START condition);
The SSPIF bit is automatically set at the end of START condition when the module is ready to operate. It should be
cleared;
Slave address should be written to the SSPBUF register; and
When the byte is sent, the SSPIF bit (interrupt) is automatically set when the acknowledge bit has been received
from the Slave device.
Data Transmit:
Data is to be send should be written to the SSPBUF register;
When the byte is sent, the SSPIF bit (interrupt) is automatically set upon the acknowledge bit has been received
from Slave device; and
In order to inform the Slave device that transmit is complete, STOP condition should be initiated by setting the PEN
bit of the SSPCON register.
Data Receive:
In order to enable receive the RSEN bit of the SSPCON2 register should be set;
The SSPIF bit signals data receive. When data is read from the SSPBUF register, the ACKEN bit of the SSPCON2
register should be set in order to enable sending acknowledge bit; and
In order to inform Slave device that transmit is complete, the STOP condition should be initiated by setting the PEN
bit of the SSPCON register.
Previous Chapter | Table of Contents | Next Chapter
http://www.mikroe.com/en/books/picmcubook/ch6/ (27 of 27)5/3/2009 11:34:00 AM