作业帮 > 综合 > 作业

做一个简易时钟(1)8位数码管显示:时-分-秒;(2)4个按键:加1键,减1键,启动键/暂停复用键,清零键;(3)按键有

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 06:30:42
做一个简易时钟
(1)8位数码管显示:时-分-秒;
(2)4个按键:加1键,减1键,启动键/暂停复用键,清零键;
(3)按键有2个用2个外部中断实现,另外2个按键用查询法实现;
(4)1s用定时中断实现;
用C语言写的
做一个简易时钟(1)8位数码管显示:时-分-秒;(2)4个按键:加1键,减1键,启动键/暂停复用键,清零键;(3)按键有
SSW EQU 53H
SGW EQU 52H
SBW EQU 55H
SQW EQU 56H
;ABC EQU 54H
COUNTER EQU 60H

BSF STATUS,RP0
CLRF TRISD
BCF TRISB,1
BCF TRISB,2
BCF TRISB,3
BCF TRISB,4
BCF STATUS,RP0
ST
MOVLW 00H
MOVWF SGW
MOVLW 00H
MOVWF SSW
MOVLW 00H
MOVWF SBW
MOVLW 00H
MOVWF SQW
;MOVWF ABC
BTFSS PORTB,0
GOTO LP1
GOTO MAIN
LP1
MOVF SGW,W
CALL CHABIAO
MOVWF PORTD
CALL DELAY
BCF PORTB,1
CALL DELAY
CALL DELAY
BSF PORTB,1

MOVF SSW,W
CALL CHABIAO
MOVWF PORTD
CALL DELAY
BCF PORTB,2
CALL DELAY
CALL DELAY
BSF PORTB,2
MOVF SBW,W
CALL CHABIAO
MOVWF PORTD
CALL DELAY
BCF PORTB,3
CALL DELAY
CALL DELAY
BSF PORTB,3

MOVF SQW,W
CALL CHABIAO
MOVWF PORTD
CALL DELAY
BCF PORTB,4
CALL DELAY
CALL DELAY
BSF PORTB,4

DECFSZ COUNTER
GOTO LP1

;BTFSS PORTC,1
;GOTO LOOP4
BTFSS PORTA,4
GOTO LP3



LP2
INCF SGW
MOVLW 0AH
SUBWF SGW,W
BTFSS STATUS,Z
GOTO LP1
BTFSS SGW,1
GOTO LP1
CLRF SGW

INCF SSW
MOVLW 0AH
SUBWF SSW,W
BTFSS STATUS,Z
GOTO LP1
BTFSS SSW,1
GOTO LP1
CLRF SSW
INCF SBW
MOVLW 0AH
SUBWF SSW,W
BTFSS STATUS,Z
GOTO LP1
BTFSS SSW,1
GOTO LP1
CLRF SBW
INCF SQW
MOVLW 0AH
SUBWF SBW,W
BTFSS STATUS,Z
GOTO LP1
CLRF SBW



GOTO LP2
LP3
MOVF SGW,W
CALL CHABIAO
MOVWF PORTD
CALL DELAY
BCF PORTB,1
CALL DELAY
CALL DELAY
BSF PORTB,1

MOVF SSW,W
CALL CHABIAO
MOVWF PORTD
CALL DELAY
BCF PORTB,2
CALL DELAY
CALL DELAY
BSF PORTB,2
MOVF SBW,W
CALL CHABIAO
MOVWF PORTD
CALL DELAY
BCF PORTB,3
CALL DELAY
CALL DELAY
BSF PORTB,3

MOVF SQW,W
CALL CHABIAO
MOVWF PORTD
CALL DELAY
BCF PORTB,4
CALL DELAY
CALL DELAY
BSF PORTB,4

DECFSZ COUNTER
GOTO LP3

BTFSS PORTB,0
GOTO LP1
GOTO LP3

;BTFSS PORTC,1
;GOTO LOOP4
;LOOP4
;MOVF ABC,W
;CALL CHABIAO
;MOVWF PORTD
;CALL DELAY
;BCF PORTB,1
;CALL DELAY
;CALL DELAY
;BSF PORTB,1

;MOVF ABC,W
;CALL CHABIAO
;MOVWF PORTD
;CALL DELAY
;BCF PORTB,2
;CALL DELAY
;CALL DELAY
;BSF PORTB,2
;MOVF ABC,W
;CALL CHABIAO
;MOVWF PORTD
;CALL DELAY
;BCF PORTB,3
;CALL DELAY
;CALL DELAY
;BSF PORTB,3

;MOVF ABC,W
;CALL CHABIAO
; MOVWF PORTD
; CALL DELAY
; BCF PORTB,4
; CALL DELAY
; CALL DELAY
; BSF PORTB,4

; DECFSZ COUNTER
; GOTO LP3

; BTFSS PORTB,0
; GOTO LP1
;GOTO LP4


CHABIAO
ADDWF PCL,F
RETLW b'11000000'
RETLW b'11111001'
RETLW b'10100100'
RETLW b'10110000'
RETLW b'10011001'
RETLW b'10010010'
RETLW b'10000010'
RETLW b'11111000'
RETLW b'10000000'
RETLW b'10010000'
RETLW b'10000001'

DELAY
DECFSZ 20H
GOTO DELAY
RETURN
END
再问: 拜托用C语言啊。大神