include c51rd2.inc Adr_lies EQU 10010001b Adr_schreib EQU 10010000b Contr_Ain0 EQU 01000000b daten EQU 0C1h clock EQU 0C0h Ain0: mov a,#Contr_Ain0 lcall Ain ret Ain: push 07 push acc lcall initI2C lcall start mov a,#Adr_schreib lcall ausgabe pop acc lcall ausgabe lcall stopp lcall start mov a,#Adr_lies lcall ausgabe lcall einlesen lcall stopp pop 07 ret initI2C: setb Daten setb Clock lcall warte ret warte : ret start: clr daten lcall warte clr clock lcall warte ret ausgabe: mov r7,#08h aloop: mov c,acc.7 mov daten,c lcall warte setb clock rl a lcall warte clr clock lcall warte djnz r7,aloop setb daten lcall warte setb clock lcall warte mov c,daten clr clock ret stopp: setb clock lcall warte setb daten lcall warte ret einlesen: lcall lies8bit clr daten lcall warte setb clock lcall warte clr clock lcall lies8bit setb daten lcall warte setb clock lcall warte clr clock lcall warte clr daten ret lies8bit: setb daten mov r7,#08h eloop: setb clock lcall warte mov c,daten mov acc.7,c rl a lcall warte clr clock lcall warte djnz r7,eloop ret