|
;EXAM7
;Display 7 Segment 2Digit Count 0-59
;
ORG 0000H
SCANCON EQU 05H ;7 Segment Scan Delay time
SEGM1 EQU P3.3 ;Control Q1 Segment 1
SEGM2 EQU P3.2 ;Control Q2 Segment 2
SEGDAT1 EQU 30H ;Reserve data for segment 1
SEGDAT2 EQU 31H ;Reserve data for segment 2
SEGDIS EQU 32H ;Segment Display Buffer
CnTM EQU 33H ;Counter duration time
START: MOV SEGDIS,#00H ;Clear Segment Display counter
RELOAD: MOV CnTM,#01FH ;Load Counter delay time
DSPLP: LCALL SEGDSP ;Display data to 7 Segment
DJNZ CnTM,DSPLP
MOV A,SEGDIS ;Get data form Segment Display Buffer
INC A ;+1
DA A ;Decimal-adjust Accumulator for addition
MOV SEGDIS,A ;Save to buffer
XRL A,#60H ;Compare with 60
JZ START ;is equal ReStart
AJMP RELOAD ;no reload Counter Time
;*** Display 7 Segment***
;IN = SEGDIS
;REG = R2,SEGDAT1,SEGDAT2
SEGDSP:
MOV A,SEGDIS ;Load Dislay Buffer to A
ANL A,#0F0H ;Clear 4 bit low
SWAP A ;swap Low nibbles and High nibbles
MOV SEGDAT1,A ;Save to Segment Data1
MOV A,SEGDIS ;Load Dislay Buffer to A
ANL A,#0FH ;Clear 4 bit High
MOV SEGDAT2,A ;Save to Segment Data2
SCAN7SEG:
;Display SEG1
MOV A,SEGDAT1 ;Load Segment 1
LCALL CNV7SEG ;Convert data to 7 segment
MOV P1,A ;Display Data
CLR SEGM1 ;On Transistor Drive SEG1
MOV R2,#SCANCON ;Delay for diaplay
LCALL DMSEC
SETB SEGM1 ;Off Transistor Drive SEG1
;Display SEG2
MOV A,SEGDAT2 ;Load Segment 2
LCALL CNV7SEG ;Convert data to 7 segment
MOV P1,A ;Display Data
CLR SEGM2 ;On Transistor Drive SEG2
MOV R2,#SCANCON ;Delay for diaplay
LCALL DMSEC
SETB SEGM2 ;Off Transistor Drive SEG2
RET
; ********** DTSEC SUB **********
; DELAY 1/10 SECOND
; IN = R2
; REG = R2,R3,R4
DTSEC: MOV R3,#179
DTSEC1: MOV R4,#0
DTSEC2: DJNZ R4,DTSEC2
NOP
NOP
DJNZ R3,DTSEC1
DJNZ R2,DTSEC
RET
; ********** DMSEC SUB **********
; DELAY 1/1000 SECOND
; IN = R2
; REG = R2,R3
DMSEC: MOV R3,#230 ;1 MSEC LOOP
DMSEC1: NOP
NOP
DJNZ R3,DMSEC1
DJNZ R2,DMSEC
RET
;*** Convert 7 Segment ***
CNV7SEG:
MOV DPTR,#SEGTBL ;LOAD TABLE POINTER
MOVC A,@A+DPTR
RET
SEGTBL: DB 0C0H,0F9H,0A4H,0B0H,99H
DB 92H,82H,0F8H,80H,90H
END
|
|