$regfile = "m16def.dat" $crystal = 8000000 $lib "lcd4busy.lib" Const _lcdport = Portb Const _lcdddr = Ddrb Const _lcdin = Pinb Const _lcd_e = 3 Const _lcd_rs = 2 Const _lcd_rw = 1 Config Sda = Portc.1 Config Scl = Portc.0 Config Lcd = 16 * 2 Dim X As String * 16 Dim Y As String * 16 Declare Sub Write_eeprom(byval Adresa_h As Byte , Adresa_l As Byte , Byval Value As Byte) Declare Sub Read_eeprom(byval Adresa_h As Byte , Adresa_l As Byte , Value As Byte) X = "Pokus s EEPROM" Cls Lcd X Lowerline Dim C As Byte , I As Byte , S As String * 1 For I = 1 To 16 Step 1 S = Mid(x , I , 1) C = Asc(s) Call Write_eeprom(1 , I , C) Next I Locate 2 , 1 For I = 1 To 16 Step 1 Call Read_eeprom(1 , I , C) Y = Y + Chr(c) Next I Lcd Y Do Wait 1 Loop Sub Write_eeprom(byval Adresa_h As Byte , Adresa_l As Byte , Byval Value As Byte) I2cstart I2cwbyte &B10101110 'adresa 24C256(zápis) I2cwbyte Adresa_h I2cwbyte Adresa_l I2cwbyte Value I2cstop Waitms 10 End Sub Sub Read_eeprom(byval Adresa_h As Byte , Adresa_l As Byte , Value As Byte) I2cstart I2cwbyte &B10101110 'adresa 24C256(zápis) I2cwbyte Adresa_h I2cwbyte Adresa_l I2cstart I2cwbyte &B10101111 'adresa 24C256(čtení) I2crbyte Value , Nack I2cstop Waitms 10 End Sub End