这是一个以1621为驱动的LCD显示,不知道那里做得不对,没看到有东西显示出来。用了4个COM口和SEG0-SEG19这几个口 ;CS equ P1.0 ;DWR equ P1.1 ;DAT equ P1.2 ORG 0000H JMP MAIN
MAIN: MOV SP,#60H SETB P1.0 MOV A,#01H ;开震荡 CALL WRIT_MODE
MOV A,#18H CALL WRIT_MODE
MOV A,#29H ;LCD1/3,4COM CALL WRIT_MODE
MOV A,#03H ;LCD 0N CALL WRIT_MODE
MAIN1: ;清屏 MOV R0,#0 MAIN2: MOV A,R0 CALL WRIT_DATA MOV A,#00H CALL WRIT_DATA0 INC R0 CJNE R0,#20,MAIN2 ;清SEG0-20 CALL TIME1
MAIN3: MOV A,#08H CALL WRIT_DATA MOV A,#0FH CALL WRIT_DATA0 JMP MAIN3
WRIT_MODE: ;100 CLR P1.0 SETB P1.2 NOP CLR P1.1 NOP SETB P1.1 NOP CLR P1.2 NOP CLR P1.1 NOP SETB P1.1 NOP CLR P1.2 NOP CLR P1.1 NOP SETB P1.1
MOV R7,#08H WRIT_MODE1: RLC A MOV P1.2,C NOP CLR P1.1 NOP SETB P1.1 NOP DJNZ R7,WRIT_MODE1
CLR P1.1 NOP SETB P1.1 SETB P1.0 RET
WRIT_DATA: ;101 CLR P1.0 SETB P1.2 NOP CLR P1.1 NOP CLR P1.1 NOP CLR P1.2 NOP CLR P1.1 NOP SETB P1.1 NOP SETB P1.2 NOP CLR P1.1 NOP SETB P1.1
MOV R7,#06H RLC A RLC A WRIT_DATA1: RLC A MOV P1.2,C NOP CLR P1.1 NOP SETB P1.1 NOP DJNZ R7,WRIT_DATA1 SETB P1.0 RET
WRIT_DATA0: CLR P1.0 MOV R7,#04H RLC A RLC A RLC A RLC A WRIT_DATA01: RLC A MOV P1.2,C NOP CLR P1.1 NOP SETB P1.1 NOP DJNZ R7,WRIT_DATA01 SETB P1.0 RET
;1s TIME1: MOV 10H,#12H G1: MOV 11H,#33H G2: MOV 12H,#6FH G3: DJNZ 12H,G3 DJNZ 11H,G2 DJNZ 10H,G3 RET
;66ms TIME2: MOV 10H,#09H M1: MOV 11H,#2CH M2: MOV 12H,#0DH M3: DJNZ 12H,M3 DJNZ 11H,M2 DJNZ 10H,M3 RET END |