基于PIC单片机电子万年历实验报告
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
实验报告
姓名:文可鑫学号:20072121010 专业:电子信息工程1编写一个秒表程序,使用查询方式。
list p=16f877a
include"p16f877a.inc"
include
count equ 20h
count_s equ 21h
org 000h
start nop
call InitSPI
banksel OPTION_REG
movlw 04h
movwf OPTION_REG
banksel INTCON
movlw 00h
movwf INTCON
movlw 06h
movwf TMR0
movlw d'131'
movwf count
movlw 00h
movwf count_s
main btfss INTCON,T0IF
goto $-1
movlw 06h
movwf TMR0
bcf INTCON,T0IF
incf count,f
btfss STATUS,Z
goto main
movlw d'131'
movwf count
incf count_s,f
movf count_s,w
sublw d'60'
btfsc STATUS,Z
clrf count_s
movf count_s,w
call Bin2BCD
movf DIS_TEMP2,w
call CHAR_CODE1
movwf DIS_TEMP2
movf DIS_TEMP1,w
call CHAR_CODE1
movwf DIS_TEMP1
call LEDlight
nop
goto main
CHAR_CODE1;共阴极字符表
ADDWF PCL,F
RETLW 3fh ;0
RETLW 06h ;1
RETLW 5bh ;2
RETLW 4fh ;3
RETLW 66h ;4
RETLW 6dh ;5
RETLW 7dh ;6
RETLW 07h ;7
RETLW 7fh ;8
RETLW 6fh ;9
Bin2BCD
CLRF DIS_TEMP1
MOVWF DIS_TEMP2
Ttenth
MOVLW .10
SUBWF DIS_TEMP2,W
BTFSS STATUS,C
GOTO OUT
MOVWF DIS_TEMP2
INCF DIS_TEMP1,F
GOTO Ttenth
OUT
RETURN
end
2编写一个秒表程序,使用中断方式。list p=16f877a
include"p16f877a.inc"
include
count equ 20h
count_s equ 21h
W_temp equ 23H
STA_temp equ 24H
org 000h
goto start
org 004h
goto intp
start nop
call InitSPI
banksel OPTION_REG movlw 44h
movwf OPTION_REG banksel INTCON
movlw 0a0h
movwf INTCON
movlw 06h
movwf TMR0
movlw d'131'
movwf count
movlw 00h
movwf count_s here goto here
intp
btfss INTCON,T0IF goto $-1
movlw 06h
movwf TMR0
bcf INTCON,T0IF incf count,f
btfss STATUS,Z
goto intp
movlw d'131'
movwf count
incf count_s,f movf count_s,w sublw d'60'
btfsc STATUS,Z
clrf count_s
movf count_s,w call Bin2BCD
movf DIS_TEMP2,w call CHAR_CODE1 movwf DIS_TEMP2 movf DIS_TEMP1,w call CHAR_CODE1 movwf DIS_TEMP1 call LEDlight
nop
RETFIE
CHAR_CODE1;共阴极字符表
ADDWF PCL,F
RETLW 3fh ;0
RETLW 06h ;1
RETLW 5bh ;2
RETLW 4fh ;3
RETLW 66h ;4
RETLW 6dh ;5
RETLW 7dh ;6
RETLW 07h ;7
RETLW 7fh ;8
RETLW 6fh ;9
Bin2BCD
CLRF DIS_TEMP1
MOVWF DIS_TEMP2 Ttenth
MOVLW .10
SUBWF DIS_TEMP2,W
BTFSS STATUS,C
GOTO OUT
MOVWF DIS_TEMP2
INCF DIS_TEMP1,F
GOTO Ttenth
OUT
RETURN
end CHAR_CODE1;共阴极字符表
ADDWF PCL,F
RETLW 3fh ;0
RETLW 06h ;1
RETLW 5bh ;2
RETLW 4fh ;3
RETLW 66h ;4
RETLW 6dh ;5
RETLW 7dh ;6
RETLW 07h ;7
RETLW 7fh ;8
RETLW 6fh ;9
Bin2BCD
CLRF DIS_TEMP1
MOVWF DIS_TEMP2 Ttenth
MOVLW .10
SUBWF DIS_TEMP2,W
BTFSS STATUS,C
GOTO OUT