PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : I2C Geräte suchen



robotikfan
02.11.2006, 10:50
Hallo,

wie kann ich nach i2c geräten suchen?
Ich habe bereits eine funktion geschrieben die jedoch nicht funktioniert.

Function I2c_search(byval Max_anzahl As Integer)as Integer
Dim I As Integer
I = 0

I2cstart
Dim Schreib_adresse As Byte
Dim Antwort As Byte
Dim Anzahl As Integer
Anzahl = 0

While I <= Max_anzahl
Antwort = ""
Schreib_adresse = Hex(i)
I2cwbyte Schreib_adresse
I2creceive Schreib_adresse , Antwort
If Antwort <> "" Then
Anzahl = Anzahl + 1
End If
Wend

I2c_search = Anzahl
Return
End Function

Vielleicht weiß jemand was ich falsch gemacht habe.

Drifter2006
02.11.2006, 14:33
Hello,

A way to check for I2C devices is:

I2Cstart
I2Cwbyte i2c_address
I2Cstop
If err = 0 then print”I2C Device found” else print”No I2C Device”

When the master sends a byte over the I2C Bus then the slave must respond with an acknowledgment.
If the slave responds then the err = 0 but if the slave does not respond (or there is no I2C device) then the err = 1

Greetings,
Windt H.J.

AVRboy
04.11.2006, 14:57
i2crecive ist doch für einen i2c slave oder und du willst doch als master auslesen.

mfg