I am using i2c library to communicate to a EEPROM 24LC08 -> Its OK.
But can I attach second EEPROM chip to another pins, and communicate with it as well?
module I2C2
' default pin settings
#option I2C2_SCL = PORTB.8
#option I2C2_SDA = PORTB.9
' timing delay
#option I2C2_DELAY_US = 5
#if IsOption(I2C2_DELAY_US) and not (I2C2_DELAY_US In(1 to 10))
IsValidPortPin(I2C2_SCL)
#error I2C2_DELAY_US, "Invalid option. I2C delay must be between 1 and 10 us."
#endif
' SCL option...
#if IsOption(I2C2_SCL) and not IsValidPortPin(I2C2_SCL)
#error I2C2_SCL, "Invalid option. I2C clock must be a valid port pin."
#endif
#option _SCL2_TRIS = GetTRIS(I2C2_SCL)
' SDA option...
#if IsOption(I2C2_SDA) and not IsValidPortPin(I2C2_SDA)
#error I2C2_SDA, "Invalid option. I2C data line must be a valid port pin."
#endif
#option _SDA2_TRIS = GetTRIS(I2C2_SDA)
' configure SCL and SDA...
private _scl_in as I2C2_SCL.I2C2_SCL@
private _sda_in as I2C2_SDA.I2C2_SDA@
private _scl as _SCL2_TRIS.I2C2_SCL@
private _sda as _SDA2_TRIS.I2C2_SDA@
private const _delayus as byte = I2C2_DELAY_US
Users browsing this forum: No registered users and 4 guests