Hi,
die Freude ist groß es funzelt !!!
Erst mal danke der Chip ließt den Wert wunderbar aus.
Hier mal der Code, wenn jemand sich noch einmal mit dem Teil auseinander
setzt:
Code:
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
Waitms 1000
'$lib "i2c_usi.lbx"
Declare Function Read_eeprom(byval Adress As Byte) As Byte
Declare Sub Write_eeprom(byval Addres As Byte , Byval Wert As Byte)
'Declare Sub Read_eeprom(byval Lesen As Byte )
Config Sda = Portd.1
Config Scl = Portd.0
'Config Scl = Portb.7 ' Ports fuer I2C-Bus
'Config Sda = Portb.5
Config Lcdpin = Pin , Db4 = Portd.6 , Db5 = Portb.0 , Db6 = Portb.1 , Db7 = Portb.2 , E = Portb.3 , Rs = Portb.4
Dim I As Bit
Config Lcd = 16 * 2 'configure lcd screen
Dim Addres As Byte
Dim Wert As Byte 'clear the LCD display
Dim Lesen As Byte
Dim Read_eeprom As Byte 'clear the LCD display
I2cinit
Cls
Waitms 1000
Addres = 1
Wert = 122
Locate 1 , 2
Lcd Chr(121)
Waitms 1000
Call Write_eeprom(addres , Wert )
I = 1
Wert = 0
Do
Locate 1 , 1
Lcd Chr(122) 'display this at the top line
If I = 1 Then
Lesen = Read_eeprom(addres)
Locate 1 , 5
Lcd Chr(122)
Locate 2 , 1
Lcd "I = " ; Lesen
Locate 2 , 6
Lcd Chr(113)
Waitms 1000
Cls
End If
Loop
End
Sub Write_eeprom(byval Addres As Byte , Byval Wert As Byte)
Locate 1 , 3
Lcd Chr(122)
I2cstart 'start condition
I2cwbyte &HA0 ' Bausteinadresse
I2cwbyte Addres ' Adresse im IC
I2cwbyte Wert ' Byte schreiben
I2cstop ' Stopbedingung
Waitms 10
Locate 1 , 4
Lcd Chr(122) ' int. Schreibzeit abwarten
End Sub
Function Read_eeprom(byval Adress As Byte )
I2cstart 'Start I2C
I2cwbyte &HA0 'sende Slave Adresse
I2cwbyte Adress 'sende Speicheradresse
I2cstart 'Start I2C
I2cwbyte &HA1 'sende Slave Adresse +1 für lesen
I2crbyte Read_eeprom , Nack 'lese Adresse vom EEprom
I2cstop
Waitms 10
Locate 2 , 1
Lcd "I = " ; Read_eeprom
Waitms 1000
'Stop I2C
End Function Read_eeprom
Eine Frage wäre noch, wie man 2 gleiche Eeproms ansteuert, an einem
Dart geht ja nicht, weil jedes Eeprom denkt es sei gemeint und in beiden
steht das gleiche.
Geht es villeicht mit:
Config Sda = Portd.1 #1
Config Scl = Portd.0 #1
Config Sda = Portd.3 #2
Config Scl = Portd.2 #2
I2cstart #1
Wie bei dem Soft-Uart oder gibt es da was anders?
Lesezeichen