How I do :
I write a sub to read one byte then I call it then number of byte to read, of course I increment the adress.
Try to imagin a street (adress of the I2C module)
in the street a lot of house (memory case)
in each house 1 people (1 byte)
So same in I2C if you want to see who is the people in the house, you need to change of adress !
-------------------------------------
Sub I2c_lit(adresse_en_prom As Word) 'read
Msb_adresse = High(adresse_prom) 'le byte haut de l'adresse oł lire
Lsb_adresse = Low(adresse_prom) 'le byte bas de l'adresse oł lire
I2cstart ' envoi un I2C Start..
I2cwbyte Commande_ecrit ' Selection du composant en ecriture
I2cwbyte Msb_adresse ' Envoi la partie haute de l'adresse
I2cwbyte Lsb_adresse ' Envoi la partie basse de l'adresse
I2cstart ' envoi un autre Start
I2cwbyte Commande_lit ' Selection du composant en lecture
I2crbyte Valeur_en_prom , Nack ' lecture...
If Err <> 0 Then ' controle le status de l'operation.
Locate 3 , 5 : Lcd "Erreur Lecture : " ; ' Report failure.0
End If
I2cstop ' Fin de la sub de lecture
End Sub
-----------------------------------------
reading of 4 bytes :
Sub Sublecture()
Adresse_prom = Adresse_prom + 200
Identite = "" : Texte = "" : Jourmois = ""
For Dummy = 1 To 4
Call I2c_lit(adresse_prom)
Texte = Str(valeur_en_prom)
Texte = Format(texte , "00")
Identite = Identite + Texte
Incr Adresse_prom
Next
JP _________________ pleasure to learn, to teach, to create
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum