《2022年PIC单片机电子万历实验分析方案.docx》由会员分享,可在线阅读,更多相关《2022年PIC单片机电子万历实验分析方案.docx(6页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、试验报告姓名:文可鑫 学号: 20072121010专业:电子信息工程1 编写一个秒表程序,使用查询方式;list p=16f877a includep16f877a.inc include countequ20h count_sequ21horg000h start nopcallInitSPIbanksel OPTION_REG movlw04hmovwfOPTION_REG banksel INTCON movlw00hmovwfINTCON movlw06h movwfTMR0 movlwd131 movwfcount movlw00h movwfcount_smainbtfssINT
2、CON,T0IF goto$-1movlw06h movwfTMR0bcfINTCON,T0IFincfcount,f btfssSTATUS,Z gotomain movlwd131 movwfcount incfcount_s,f movfcount_s,w sublwd60 btfscSTATUS,Z clrfcount_s movfcount_s,w callBin2BCDmovfDIS_TEMP2,w callCHAR_CODE1 movwfDIS_TEMP2movfDIS_TEMP1,w callCHAR_CODE1 movwfDIS_TEMP1 callLEDlightnopgo
3、tomain CHAR_COD;E1共阴极字符表ADDWFPCL,FRETLW 3fh;0RETLW 06h;1RETLW 5bh;2RETLW 4fh;3RETLW 66h;4RETLW 6dh;5RETLW 7dh;6RETLW 07h;7RETLW 7fh;8RETLW 6fh;9Bin2BCDCLRFDIS_TEMP1 MOVWFDIS_TEMP2TtenthOUTendMOVLW.10 SUBWFDIS_TEMP2,W BTFSS STATUS,C GOTO OUT MOVWFDIS_TEMP2 INCFDIS_TEMP1,FGOTO TtenthRETURN2 编写一个秒表程序,使
4、用中断方式;list p=16f877a includep16f877a.inc include countequ20h count_sequ21h W_tempequ 23H STA_temp equ 24Horg 000h goto start org 004h goto intpstart nopcallInitSPIbanksel OPTION_REG movlw44hmovwfOPTION_REG banksel INTCON movlw0a0hmovwfINTCON movlw06h movwfTMR0 movlwd131 movwfcount movlw00h movwfcoun
5、t_sheregotohere intpbtfssINTCON,T0IF goto$-1movlw06hmovwfTMR0bcfINTCON,T0IFincfcount,f btfssSTATUS,Z gotointp movlwd131 movwfcount incfcount_s,fmovfcount_s,w sublwd60 btfscSTATUS,Z clrfcount_s movfcount_s,w callBin2BCDmovfDIS_TEMP2,w callCHAR_CODE1 movwfDIS_TEMP2 movfDIS_TEMP1,w callCHAR_CODE1 movwf
6、DIS_TEMP1 callLEDlightnop RETFIECHAR_CODE;1共阴极字符表 ADDWFPCL,FRETLW 3fh;0RETLW 06h;1RETLW 5bh;2RETLW 4fh;3RETLW 66h;4RETLW 6dh;5RETLW 7dh;6RETLW 07h;7RETLW 7fh;8RETLW 6fh;9Bin2BCDCLRFDIS_TEMP1 MOVWFDIS_TEMP2TtenthOUTMOVLW.10 SUBWFDIS_TEMP2,W BTFSS STATUS,C GOTO OUT MOVWFDIS_TEMP2 INCFDIS_TEMP1,FGOTO T
7、tenthRETURNend CHAR_CODE;1共阴极字符表 ADDWFPCL,FRETLW 3fh;0RETLW 06h;1RETLW 5bh;2RETLW 4fh;3RETLW 66h;4RETLW 6dh;5RETLW 7dh;6RETLW 07h;7RETLW 7fh;8RETLW 6fh;9Bin2BCDCLRFDIS_TEMP1 MOVWFDIS_TEMP2TtenthMOVLW.10 SUBWFDIS_TEMP2,W BTFSS STATUS,C GOTO OUT MOVWFDIS_TEMP2OUTendINCFDIS_TEMP1,FGOTO Ttenth RETURNlis
8、t p=16f877a includep16f877a.inc include countequ20h count_sequ21horg 000h goto start org 004h goto intpstart nopcallInitSPIbanksel OPTION_REG movlw04hmovwfOPTION_REGbanksel INTCON movlw00h movwfINTCON movlw06h movwfTMR0 movlwd131 movwfcount movlw00h movwfcount_sheregotohereintpbtfssINTCON,T0IF goto$
9、-1movlw06hmovwfTMR0bcfINTCON,T0IFincfcount,f btfssSTATUS,Z gotointp movlwd131 movwfcount incfcount_s,fmovfcount_s,w sublwd60 btfscSTATUS,Z clrfcount_smovfcount_s,w callBin2BCDmovfDIS_TEMP2,w callCHAR_CODE1 movwfDIS_TEMP2 movfDIS_TEMP1,w callCHAR_CODE1 movwfDIS_TEMP1 callLEDlightnop RETFIECHAR_CODE;1共阴极字符表ADDWFPCL,FRETLW 3fh;0RETLW 06h;1RETLW 5bh;2RETLW 4fh;3RETLW 66h;4RETLW 6dh;5RETLW 7dh;6RETLW 07h;7RETLW 7fh;8RETLW 6fh;9Bin2BCDCLRFDIS_TEMP1 MOVWFDIS_TEMP2TtenthOUTendMOVLW.10 SUBWFDIS_TEMP2,W BTFSS STATUS,C GOTO OUT MOVWFDIS_TEMP2 INCFDIS_TEMP1,FGOTO Ttenth RETURN