User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
341
I2Cx_Read
Prototype
unsigned char I2Cx_Read(unsigned ack);
Description Reads a byte from the I²C bus.
Parameters - ack: acknowledge signal parameter. If the ack = 0, acknowledge signal will be sent after reading,
otherwise the not acknowledge signal will be sent.
Returns Received data.
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 take;
...
// Read data and send the not_acknowledge signal
take = I2C1_Read(1);
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 5.
- Number of I²C modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.
I2Cx_Write
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 5.
- Number of I²C modules per MCU differs from chip to chip. Please, read the appropriate datasheet
before utilizing this library.