Hmmm... woran liegt es nur, dass das nicht will wie ich? 
Hab es gerade noch mal getestet aber es funktioniert noch nicht.
Hier mal der aktuelle Code:
Code:
' BASCOM-Programm
' I2C-Scanner mit ATMega8
'
' In: beliebige I2C-Slaves an C.4=SDA und C.5=SCL
' Out: SerialOut über UART
' Funktion dieses Demo-Programmes:
' Scannen der Slave-Adressen
'$sim
$regfile = "m8def.dat" ' benutzter Mikrocontroller
$crystal = 8000000 ' Taktfrequenz
$hwstack = 40 ' Hardware Stack
$swstack = 32 ' SW Stack
$framesize = 60 ' Frame
$baud = 9600
Waitms 250
Config Sda = Portc.4
Config Scl = Portc.5
Config I2cdelay = 10
I2cinit
Dim Slaveadresse As Byte
Dim Lux As Byte
Lux = 0
Dim Lux01 As Byte
Dim Lux02 As Byte
Do
Print "I2C Slaves"
Print "suchen..."
Wait 2
For Slaveadresse = 0 To 254 Step 1 ' für alle geraden Adressen
I2cstart 'Startbedingung senden
I2cwbyte Slaveadresse ' Addresse senden
If Err = 0 Then 'I2C-Slave gefunden?
Print "Slave dec: " ; Slaveadresse
Print "h" ; Hex(slaveadresse) ; " b" ; Bin(slaveadresse)
Wait 2
End If
I2cstop 'Bus freigeben
Next
Print "Ende Scan"
Wait 2
I2cstart
I2cwbyte &H72 , Lux
If Err = 0 Then
Print "Lux72: " ; Lux
Waitms 250
Else
Print "Lux72: no ACK"
End If
I2cstop
I2cstart
I2cwbyte &H73 , Lux
If Err = 0 Then
Print "Lux73: " ; Lux
Waitms 250
Else
Print "Lux73: no ACK"
End If
I2cstop
I2cstart
I2cwbyte &H74 , Lux
If Err = 0 Then
Print "Lux74: " ; Lux
Waitms 250
Else
Print "Lux74: no ACK"
End If
I2cstop
I2cstart
I2cwbyte &H75 , Lux
If Err = 0 Then
Print "Lux75: " ; Lux
Waitms 250
Else
Print "Lux75: no ACK"
End If
I2cstop
I2cinit
I2cstart
I2cwbyte 57 '0x39
I2cwbyte 140 '0x8C
I2crbyte Lux01 , Ack
I2cwbyte 109 '0x6d
I2crbyte Lux02 , Nack
Print "erster Wert: " ; Lux01
Print "zweiter Wert: " ; Lux02
I2cinit
Loop
End
Und was Hterm dabei ausgibt:

Falls da mal jemand drüber schauen kann und mir evtl. Fehler im Code aufzeigt, damit ich nachbessern kann...
Viele Grüße
e.
Lesezeichen