User manual

mikroC PRO for dsPIC
MikroElektronika
393
I2Cx_Write
I2Cx_Stop
Prototype
unsigned I2Cx_Write(unsigned char data_);
Description Sends data byte via the I²C bus.
Parameters - data_: data to be sent
Returns - 0 if there were no errors.
- 1 if write collision was detected on the I²C bus.
Requires MCU with at least one I²C module.
Used I²C module must be initialized before using this function. See I2Cx_Init routine.
Also, START signal needs to be issued in order to use this function. See I2Cx_Start.
Example
unsigned char data_;
unsigned error;
...
error = I2C1_Write(data_);
error = I2C1_Write(0xA3);
Notes I²C library routines require you to specify the module you want to use. To select the desired I²C
module, simply change the letter x in the routine prototype for a number from 1 to 3.
Number of I²C modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.
Prototype
void I2Cx_Stop();
Description Issues STOP signal.
Parameters None.
Returns Nothing.
Requires MCU with at least one I²C module.
Used I²C module must be initialized before using this function. See I2Cx_Init routine.
Example
// Issue STOP signal
I2C1_Stop();
Notes I²C library routines require you to specify the module you want to use. To select the desired I²C
module, simply change the letter x in the routine prototype for a number from 1 to 3.
Number of I²C modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.