Hi,

hat dieses Congig was mit dem Usi zu tun, da ich die Lib nicht verwede.

Hier mal das neue Prog mit der Funktion:

Code:
$regfile = "Attiny2313.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
Waitms 1000
'$lib "i2c_usi.lbx"




Declare Function Read_eeprom(byval Lesen 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(lesen)
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
    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

Function Read_eeprom(byval Lesen As Byte )
    I2cstart                                                'start condition
    Waitms 1
    I2cwbyte &B10100001                                     ' Bausteinadresse
    Waitms 1
    I2crbyte Read_eeprom
    Waitms 1
    I2cstop                                                 ' Stopbedingung
    Waitms 10
    Lesen = Read_eeprom
End Function Read_eeprom