PN I2C-TREIBER ; ORG 08000H PIIC: EQU 056H ; JMPV: JMP TPROG JMP INIT JMP RUFE JMP READ JMP SEND JMP RBYTE JMP SBYTE JMP START JMP STOP ICADR: DB 022H ; TPROG: CALL INIT CALL RUFE RST 038H ; ; Grundroutinen für ; I2C-Steuerung ; READ: CALL START LD A,(ICADR) INC A CALL SBYTE JPNZ NOIC PUSH BC LD B,D LD C,E RLP: LD D,1 DEC BC LD A,B OR A JRNZ RLP2-# LD D,C RLP2: CALL RBYTE LD M,A INC HL LD A,B OR C JRNZ RLP-# POP BC CALL STOP RET SEND: CALL START LD A,(ICADR) CALL SBYTE JPNZ NOIC PUSH BC LD B,M SLP: INC HL LD A,M CALL SBYTE JPNZ ERROR DJNZ SLP-# POP BC CALL STOP RET RBYTE: PUSH BC LD A,2 OUT PIIC LD B,8 RLOOP: SET 0,A OUT PIIC IN PIIC BIT 3,A SCF JRZ RHI-# CCF RHI: RL C RES 0,A OUT PIIC DJNZ RLOOP-# XOR A CMP D JRNZ REND-# LD A,2 REND: OUT PIIC SET 0,A OUT PIIC RES 0,A OUT PIIC SET 1,A OUT PIIC LD A,C POP BC RET SBYTE: PUSH BC LD B,8 LD C,A XOR A SLOOP: SET 1,A RLC C JRC SHI-# RES 1,A SHI: OUT PIIC SET 0,A OUT PIIC RES 0,A OUT PIIC DJNZ SLOOP-# POP BC SET 1,A OUT PIIC SET 0,A OUT PIIC IN PIIC CPL BIT 3,A CPL RES 0,A OUT PIIC RET START: PUSH AF LD A,1 OUT PIIC XOR A OUT PIIC POP AF RET STOP: PUSH AF XOR A OUT PIIC OR 1 OUT PIIC OR 3 OUT PIIC POP AF RET INIT: LD A,0FFH OUT PIIC OUT PIIC+1 LD A,0FCH OUT PIIC+1 CALL STOP RET ERROR: RST 020H DB 2 DB 13 DB 'Fehler.' DB 08DH CALL STOP RST 038H RUFE: LD D,0 RNXT: LD A,D CALL START CALL SBYTE CAZ IDENT CALL STOP INC D LD A,D OR A JRNZ RNXT-# RET NOIC: LD A,(ICADR) LD D,A CALL IDM RST 020H DB 2 DB 'nicht.' DB 08DH CALL STOP RST 038H IDENT: CALL IDM RST 020H DB 2,8 DB '.',08DH RET IDM: CALL NAME RST 020H DB 2 DB ' meldet' DB ' sich' DB 0A0H RET NAME: RST 020H DB 2 DB 'IC' DB 0A0H LD A,D RST 020H DB 6 RET END ; END Hardware-Anschluß: Pin 0: SCL out Pin 1: SDA out Pin 2: SCL in Pin 3: SDA in erste Meldungen des SAA 5243 (022H) am 16.9.93 !