User manual

mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
369
I2Cx_Write
I2Cx_Stop
Prototype
sub function I2Cx_Write(dim data_ as byte) as word
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
dim data_ as byte
error as word
...
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
sub procedure 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.