Sunteți pe pagina 1din 1

Device = 16F876 XTAL 20 ALL_DIGITAL = True Declare SCL_PIN PORTB.0 Declare SDA_PIN PORTB.

Dim TX As PORTB.2 Dim DATA_OUT As Byte Dim DATA_IN(20) As Byte Dim Address As Word For Address = 1 To 20 DATA_OUT = Address BStart ' Send the start command on I2C ' Send the byte to the EEPROM BusOut %10100010,Address,[DATA_OUT] BStop ' Send the stop command on I2C DelayMS 5 ' Allow time for allocation of byte Next Address For Address = 1 To 20 BStart ' Send the start command on I2C ' Send the address to read BusOut %10100010,[Address] Brestart ' Send a restart command on I2C ' Grab data at the above address BusIn %10100011, [DATA_IN[Address]] BStop ' Send the stop command on I2C Next Address Stop ' 16-bit address required

S-ar putea să vă placă și