; FILENAME X93C46.ASM ; DESCRIPTION EXAMPLE PROGRAM FOR 93C46 EEPROM ; HARDWARE JAZZ-31 & 93C46 AT PORT1 ; ASSEMBLER SXA51 ; ENGINEER KRIANGSAK B. ; COMPANY SILA RESEARCH CO.,LTD. ; I/O PORT 93C46 JAZZ-31 ; ======== ========== ; PIN-2 SK --- PIN-1 P1.0 ; PIN-3 DI --- PIN-2 P1.1 ; PIN-4 DO --- PIN-3 P1.2 ; PIN-1 CS --- PIN-4 P1.3 ; FUNCTION WRITE 93H,46H TO 93C46 AT ADDRESS 07H ; READ ADDRESS 07H AND GOTO JAZZ-31 MONITOR ; ********** VARIABLE ********** EEPCLK EQU P1.0 EEPDI EQU P1.1 EEPDO EQU P1.2 EEPCS EQU P1.3 ; ********** MAIN ********** ORG 8100H MAIN: CLR EEPCLK CLR EEPCS LCALL EEPEN ;ENABLE FIRST MOV R2,#07H LCALL EEPER ;ERASE MOV R2,#07H MOV R3,#93H MOV R4,#46H LCALL EEPWR ;WRITE MOV R3,#0 MOV R4,#0 MOV R2,#07H LCALL EEPRD LJMP 0036H ; ********** EEPRD SUB ********** ; 93C46 READ WORD SUBROUTINE ; IN = R2 ADDRESS (0-63) ; OUT = R3,R4 DATA ; REG = A,R2,R3,R4 EEPRD: MOV A,R2 ANL A,#00111111B ;MAKE SURE DATA=6 BIT ORL A,#10000000B ;OPCODE SETB EEPCS ;CS=1 SETB EEPDI ;START BIT LCALL CLOCK MOV R2,#8 ;OPCODE,ADDRESS EEPRD2: RLC A MOV EEPDI,C LCALL CLOCK DJNZ R2,EEPRD2 MOV R2,#8 ;READ DATA (8 BIT FIRST) EEPRD4: LCALL CLOCK MOV C,EEPDO RLC A DJNZ R2,EEPRD4 MOV R3,A MOV R2,#8 ;READ DATA (8 BIT LAST) EEPRD5: LCALL CLOCK MOV C,EEPDO RLC A DJNZ R2,EEPRD5 MOV R4,A CLR EEPCS ;CS=0 RET CLOCK: SETB EEPCLK ;SYNC CLOCK NOP NOP CLR EEPCLK NOP NOP RET ; ********** EEPWR SUB ********** ; 93C46 WRITE WORD SUBROUTINE ; IN = R2 ADDRESS (0-63) ; = R3,R4 DATA ; REG = A,R2 EEPWR: MOV A,R2 ANL A,#00111111B ;MAKE SURE DATA=6 BIT ORL A,#01000000B ;OPCODE SETB EEPCS ;CS=1 SETB EEPDI ;START BIT LCALL CLOCK MOV R2,#8 ;OPCODE,ADDRESS EEPWR2: RLC A MOV EEPDI,C LCALL CLOCK DJNZ R2,EEPWR2 MOV R2,#8 ;WRITE DATA (8 BIT FIRST) MOV A,R3 EEPWR4: RLC A MOV EEPDI,C LCALL CLOCK DJNZ R2,EEPWR4 MOV R2,#8 ;WRITE DATA (8 BIT LAST) MOV A,R4 EEPWR5: RLC A MOV EEPDI,C LCALL CLOCK DJNZ R2,EEPWR5 CLR EEPCS ;CS=0 NOP NOP SETB EEPCS ;CS=1 (CHECK STATUS) NOP NOP JNB EEPDO,$ ;WAIT FOR BUSY NOP NOP CLR EEPCS ;CS=0 RET ; ********** EEPER SUB ********** ; 93C46 ERASE WORD SUBROUTINE ; IN = R2 ADDRESS (0-63) ; REG = A,R2 EEPER: MOV A,R2 ANL A,#00111111B ;MAKE SURE DATA=6 BIT ORL A,#11000000B ;OPCODE SETB EEPCS ;CS=1 SETB EEPDI ;START BIT LCALL CLOCK MOV R2,#8 ;OPCODE,ADDRESS EEPER2: RLC A MOV EEPDI,C LCALL CLOCK DJNZ R2,EEPER2 CLR EEPCS ;CS=0 NOP NOP SETB EEPCS ;CS=1 (CHECK STATUS) NOP NOP JNB EEPDO,$ ;WAIT FOR BUSY NOP NOP CLR EEPCS ;CS=0 RET ; ********** EEPEN SUB ********** ; 93C46 ENABLE SUBROUTINE ; REG = A,R2 EEPEN: MOV A,#00110000B ;OPCODE SETB EEPCS ;CS=1 SETB EEPDI ;START BIT LCALL CLOCK MOV R2,#8 ;OPCODE,ADDRESS EEPEN2: RLC A MOV EEPDI,C LCALL CLOCK DJNZ R2,EEPEN2 RET END
RETURN TO MAIN MENU |