新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機(jī)控制時鐘顯示源程序

單片機(jī)控制時鐘顯示源程序

作者: 時間:2012-10-31 來源:網(wǎng)絡(luò) 收藏

;==============拆分子程序=====================
Separate:
MOV DPTR,#TAB1
;-------------------
MOV A,SECOND
MOVC A,@A+DPTR ;查表,十六進(jìn)制轉(zhuǎn)為十進(jìn)制數(shù)
mov R0,A ;R0暫存A中的數(shù)
ANL A,#0FH ;屏蔽高4位
MOV Second_0, A ;送秒個位
MOV A,R0 ;恢復(fù)A中數(shù)
ANL A, #0F0H ;屏蔽低4位
SWAP A ;高4位與低4位交換
MOV Second_1,A ;送秒十位
;--------------------
MOV LED2,#0FFH ;數(shù)碼管滅的顯示代碼
;--------------------
MOV A,MINUTE
MOVC A,@A+DPTR
mov R0,A
ANL A,#0FH
MOV Minute_0, A
MOV A,R0
ANL A, #0F0H
SWAP A
MOV Minute_1,A
;-----------------------
MOV LED5,#0FFH ;數(shù)碼管滅的顯示代碼
;-----------------------
MOV A,HOUR
MOVC A,@A+DPTR
ANL A,#0FH
MOV Hour_0, A
MOV A,HOUR
ANL A, #0F0H
SWAP A
MOV Hour_1,A
RET
;-----------------------
TAB1: DB 00H,01H,02H,03H,04H,05H,06H,07H,08H,09H ; 十六進(jìn)制轉(zhuǎn)十進(jìn)制數(shù)表
DB 10H,11H,12H,13H,14H,15H,16H,17H,18H,19H
DB 20H,21H,22H,23H,24H,25H,26H,27H,28H,29H
DB 30H,31H,32H,33H,34H,35H,36H,37H,38H,39H
DB 40H,41H,42H,43H,44H,45H,46H,47H,48H,49H
DB 50H,51H,52H,53H,54H,55H,56H,57H,58H,59H
DB 60H,61H,62H,63H,64H,65H,66H,67H,68H,69H
DB 70H,71H,72H,73H,74H,75H,76H,77H,78H,79H
DB 80H,81H,82H,83H,84H,85H,86H,87H,88H,89H
DB 90H,91H,92H,93H,94H,95H,96H,97H,98H,99H
;===================顯示子程序=====================
DISPLAY:
MOV DPTR,#TAB2 ;送顯示代碼首地址
MOV A,Second_0 ;秒個位送A
MOVC A,@A+DPTR ;顯示代碼查表
ACALL SHIFT ;調(diào)移位子程序
MOV A,Second_1
MOVC A,@A+DPTR
ACALL SHIFT
MOV A,LED2
MOVC A,@A+DPTR
ACALL SHIFT
MOV A,Minute_0
MOVC A,@A+DPTR
ACALL SHIFT
MOV A,Minute_1
MOVC A,@A+DPTR
ACALL SHIFT
MOV A,LED5
MOVC A,@A+DPTR
ACALL SHIFT
MOV A,Hour_0
MOVC A,@A+DPTR
ACALL SHIFT
MOV A,Hour_1
MOVC A,@A+DPTR
ACALL SHIFT
RET
;----------------------------------------------
TAB2: DB 11H,0D7H,32H,92H,0D4H,98H,18H,0D3H ;0,1,2,3,4,5,6,7 顯示代碼
DB 10H,90H,50H,1CH,39H,16H,38H,78H,0FFH ;8,9,A,B,C,D,E,F,滅
;---------------------------------------------
;================移位子程序==================
SHIFT: push a ;A進(jìn)棧暫存
MOV R2,#8
CLR C
CLR SCL
DL:
RLC A
MOV SDA,C
SETB SCL
CLR SCL
DJNZ R2,DL
pop a ;出?;謴?fù)A值
RET
;============延時約一秒子程序=============
DELAY_1S: MOV R6,#1FH
LOOP7: MOV R5,#0FFH
LOOP6: NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DJNZ R5,LOOP6
DJNZ R6,LOOP7
RET
END
完整程序請從這里下:http://www.51hei.com/ziliao/file/shiz.rar ,本人已經(jīng)測試通過.


上一頁 1 2 下一頁

關(guān)鍵詞: 單片機(jī) 控制時鐘 顯示源程序

評論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉