141 of 318
ZBasic System Library 131 ZX Microcontroller Family I2CPutByte Type Function return Boolean Invocation I2CPutByte(channel, dataVal) Parameter Method Type Description channel ByVal Byte The I2C channel number (0-4). dataVal ByVal Byte The data byte to send to the slave. Discussion This function transmits a data value to an I2C slave and reads the acknowledgement bit returned by the slave. The value returned by this function is the value of the acknowledge bit received from the slave device – a positive acknowledgement results in a True value being returned. This function can be used in conjunction with I2CStart(), I2CGetByte() and I2CStop() to perform a lower level interaction with an I2C slave device. Knowledge of the I2C protocol and the specifications of the particular I2C device are required in order to use this function. If the specified I2C channel has not been properly prepared using OpenI2C(), the results are undefined. If an invalid channel number is specified, the function returns immediately without doing anything. Resource Usage This function uses the for channels 1 to 4. If the timer is already in use, the function will do nothing and the return value is undefined. Interrupts are disabled for about 9 times the selected I2C bit time plus additional amounts due to slave clock stretching. However, RTC ticks are accumulated during the process so the RTC should not lose time. Compatibility This function is not available in BasicX compatibility mode. See Also OpenI2C, CloseI2C, I2CGetByte, I2CStart, I2CStop, I2CCmd