AT93C46/56/55串行EEPROM及单片机程序
DECLARE SETCS LITERALLY ‘CALL BITSET. IO-PORT2,0′;
DECLARE CLRCS LITERALLY ‘CALL BITCLR. IOPORT2,0′;
DECLARE SETCLK LITERALLY ‘CALL BITSET. IOPORT2,5′;
DECLARE CLRCLK LITERALLY ‘CALL BITCLR. IOPORT2,5′;
DECLARE SETDI LITERALLY ‘CALL BITSET. IO-PORT1,5′;
DECLARE CLRDI LITERALLY ‘CALL BITCLR. IOPORT1,5′;
EWEN:PROCEDURE PUBLIC;
DECLARE I BYTE;
CLRCS; CLRDI; CLRCLK;
SETCS; SETDI; SETCLK;
DO I=1 TO 2;
CLRCLK; CLRDI; SETCLK;
END;
DO I=1 TO 2;
CLRCLK; SETDI; SETCLK;
END;
DO I = 0 TO 6;
CLRCLK; SETDI; SETCLK;
END;
CLRCLK; CLRCS; SETCS;
SETCLK; CLRCLK;
END EWEN;
READ:PROCEDURE(ADDR) PUBLIC;
DECLARE (ADDR,I,COUNT) BYTE;
CLRCS; CLRDI;
CLRCLK; SETCS;
DO I= 1 TO 2;
CLRCLK; SETDI; SETCLK;
END;
DO I =1 TO 2;
CLRCLK; CLRDI; SETCLK;
DO COUNT=1 TO 7;
BITOUT(COUNT)=SHR(BITOUT(COUNT),1);
END;
CLRCS; CLRDI; CLRCLK;
CALL TIME(100);
SETCS; CLRC;
END READ;
WRITE: PROCEDURE(ADDR,DATA) PUBLIC;
DECLARE (ADDR,DATA) BYTE;
CLRCS; CLRDI; CLRCLK;
SETCS; SETDI; SETCLK;
CLRDI; CLRCLK; SETCLK;
SETDI; CLRCLK; SETCLK;
END;
DO I =-1 TO 8;
X=ROL(ADDR,1);
ADDR=X; CLRCLK;
IF ((X AND 01H)=01H)THEN SETDI;
ELSE CLRDI;
SETCLK;
END;
DO I =1 TO 7;
CLRCLK; SETCLK;
END;
DO I =1 TO 8
CALL BITSET(.IOPORT1,7);
COUNT=COUNT-1;
CLRCLK; SETCLK;
BITOUT(COUNT)=IOPORT1;
END;
CLRCLK; SETCLK;
J=0;
AA: DO I= 1 TO 8;
J=J+1;
X=ROL(ADDR,1;
ADDR=X; CLRCLK;
IF((X AND 01H)=01H) THEN SETDI
ELSE CLRDI;
SETCLK;
END;
IF J<>16 THEN DO;
ADDR =DATA;
GOTO AA;
END;
CLRCS;SETCS;
CALL TIME(100);
END;