|
發表於 2013-12-21 12:17:11
|
顯示全部樓層
本帖最後由 ysc 於 2013-12-21 12:19 PM 編輯
附上程式:
$MOD52
$TITLE(SBC-51 4 BIT LED TEST)
$OBJECT
$NOSYMBOLS
$PAGEWIDTH(80)
;
D_595 EQU P1.4
CK_595 EQU P1.5
E_595 EQU P1.6
;--------------------------------------
CSEG AT 0H
ORG 0 ;RESET
JMP START
;--------------------------------------
START:
CLR EA ;DIS INT
ORL 8EH,#1 ;DIS ALE
MOV PSW,#0
;
MOV R0,#1
CLR_RAM:
MOV @R0,#0
INC R0
MOV A,R0
JNZ CLR_RAM
;
MOV SP,#80H
MOV A,#0FFH
MOV P1,A
MOV P2,A
MOV P3,A
;
CLR E_595
CLR CK_595
CALL INI_LCD
;
MAIN:
MOV DPTR,#LINE1
ACALL DS_MSG
;
MOV A,#0C0H
ACALL WR_COM
;
MOV DPTR,#LINE2
ACALL DS_MSG
;
LOOP:
SJMP LOOP
;
DS_MSG:
CLR A
MOVC A,@A+DPTR
JNZ DS_MSG2
RET
DS_MSG2:
ACALL WR_DATA
INC DPTR
SJMP DS_MSG
;
LINE1:
DB ' HELLO PIGOO',0
LINE2:
DB '4 BIT LCD WITH HC595',0
;------------------------------------------------
INI_LCD:
;
CLR A
ACALL W_595
ACALL LCD_DLY
ACALL LCD_DLY
;
MOV A,#30H
ACALL WR_INIT
MOV A,#30H
ACALL WR_INIT
MOV A,#30H
ACALL WR_INIT
MOV A,#20H
ACALL WR_INIT
MOV A,#28H
ACALL WR_COM
MOV A,#0CH
ACALL WR_COM
MOV A,#01H
ACALL WR_COM
MOV A,#06H
ACALL WR_COM
MOV A,#80H
ACALL WR_COM
RET
;
WR_INIT:
ACALL WR_COM1
SJMP LCD_DLY
;
WR_COM:
PUSH ACC
ACALL WR_COM1
POP ACC
SWAP A
ACALL WR_COM1
LCD_DLY:
MOV R3,#20
LCD_DLY1:
MOV R2,#0
DJNZ R2,$
DJNZ R3,LCD_DLY1
RET
;
WR_COM1:
ANL A,#0F0H
SETB ACC.3
ACALL W_595
CLR ACC.3
ACALL W_595
RET
;
WR_DATA:
PUSH ACC
ACALL WR_DATA1
POP ACC
SWAP A
ACALL WR_DATA1
MOV R3,#4
SJMP LCD_DLY1
;
WR_DATA1:
ANL A,#0F0H
ORL A,#0AH
ACALL W_595
CLR ACC.3
ACALL W_595
RET
;
W_595:
PUSH ACC
MOV R7,#8
W_595_1:
RLC A
MOV D_595,C
SETB CK_595
CLR CK_595
DJNZ R7,W_595_1
;
SETB E_595
CLR E_595
POP ACC
RET
;---------------------------------------------------
END
|
|