Specifications

mikroElektronika | Free Online Book | PIC Microcontrollers | Chapter 6: Serial Communication Modules
SEN - START Condition Enabled/Stretch Enabled bit
In I²C Master mode only
1 - Initiate START condition on pins SDA and SCL. Afterwards, this bit is automatically cleared by hardware; and
0 - START condition is not initiated.
I²C in Master Mode
The most common case is when the microcontroller operates as a master and the peripheral component as a slave. This is
why this book covers just this mode. It is also considered that the address consists of 7 bits and device contains only one
microcontroller (one master device).
In order to enable MSSP module in this mode, it is necessary to do the following:
Set baud rate (SSPADD register), turn off slew rate control (by setting the SMP bit of the SSPSTAT register) and select
master mode (SSPCON register). After the preparation has been finished and module has been enabled (SSPCON register:
SSPEN bit), one should wait for internal electronics to signal that everything is ready for data transmission, i.e. the SSPIF
bit of the PIR1 register is set.
This bit should be cleared by software and after that, the microcontroller is ready to start "communication" with
peripherals.
Fig. 6-27 I²C in Master Mode
Data Transmission in I²C Master Mode
Each clock condition on the SDA pin starts with logic zero (0) which appears upon setting the SEN bit of the SSPCON2
register. Even enabled, the microcontroller has to wait a certain time before it starts communication. It is the so called
"Start condition" during which internal preparations and checks are performed. If all conditions are met, the SSPIF bit of
the PIR1 is set and data transfer starts as soon as the SSPBUF register is loaded.
http://www.mikroe.com/en/books/picmcubook/ch6/ (23 of 27)5/3/2009 11:34:00 AM