Hi,
ich habe mal den Code modivieziert. Funktuniert aber auch nicht:
Code:
$regfile = "2313def.dat" ' specify the used micro
$crystal = 1000000 ' used crystal frequency
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
Declare Sub Read_eeprom(byval Lesen As Byte)
Declare Sub Write_eeprom(byval Addres As Byte , Byval Wert As Byte)
Config Sda = Portd.1
Config Scl = Portd.0
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
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
Call Read_eeprom(lesen)
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
Waitms 1
I2cwbyte &B10101110 ' Bausteinadresse
Waitms 1
I2cwbyte &B11111111 ' Adresse im IC
Waitms 1
I2cwbyte Wert ' Byte schreiben
Waitms 1
I2cstop ' Stopbedingung
Waitms 10
Locate 1 , 4
Lcd Chr(122) ' int. Schreibzeit abwarten
End Sub
Sub Read_eeprom(byval Lesen As Byte)
Locate 1 , 5
Lcd Chr(122)
I2cstart 'start condition
Waitms 1
I2cwbyte &B10100001 ' Bausteinadresse
Waitms 1
I2crbyte Lesen
Waitms 1
I2cstop ' Stopbedingung
Waitms 10
Locate 1 , 6
Lcd Chr(122) ' int. Schreibzeit abwarten
End Sub
Meine Fragen wären noch:
Sind 22k gegen Plus in Ordnung?
Gibt es ein Unterscheid zwischen Hard und Software I²C?
Lesezeichen