Example... this assumes that your external EEPROM has a device address of $A0 (see your chosen EEPROM's Datasheet) and is of the 24LC32/24LC64 type). SCL is the PIC pin you are using for the I2C Clock line, SDA is the PIC pin you are using for the I2C Data line.
and the opposite to read...Code:' ' Subroutine Writes BYTE to External EEPROM ' ------------------------------------------ SetDataExternal: ' I2CData - General BYTE variable ' I2CDeviceAddress - Hardware Device Address - BYTE variable ' I2CDataAddress - Address in EEPROM - WORD variable I2CDeviceAddress=$A0 I2CWrite SDA,SCL,I2CDeviceAddress,I2CDataAddress,[I2CData] Pause 10 Return
For further information lookup the I2CREAD and I2CWRITE commands in your PBP manual and compare the examples against the EEPROM Datasheet.Code:' ' Subroutine Reads BYTE from External EEPROM ' ----------------------------------------- GetDataExternal: ' I2CData - General BYTE variable ' I2CDeviceAddress - Hardware Device Address - BYTE variable ' I2CDataAddress - Address in EEPROM - WORD variable I2CDeviceAddress=$A0 I2CRead SDA,SCL,I2CDeviceAddress,I2CDataAddress,[I2CData] Return




Bookmarks