Mikroelektronika MIKROE-738 Datenbogen
![Mikroelektronika](https://files.manualsbrain.com/attachments/e0529b3b58069a916ad7bb89f7e9f5f0eda73421/common/fit/150/50/1b07b99aa3112e022a916b06db07f1f4f211e91d41878452d87c7638b1bf/brand_logo.gif)
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 -
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 -
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.