"); //-->
代码
#include<p16f877.inc> __CONFIG(_CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF& _CPD_OFF); cblock 0x20 microSec :2 ms50 second minute hour endc w_temp equ 0x30 status_temp equ 0x31 pch_temp equ 0x32 fsr_temp equ 0x33 org 0x0000 goto main org 0x0004 ;banksel w_temp movwf w_temp movf STATUS,w clrf STATUS MOVWF status_temp movf PCLATH,w movwf pch_temp MOVF FSR,W MOVWF fsr_temp clrf PCLATH bcf INTCON,T0IF MOVLW 0X10 ADDWF microSec+1,f goto EndOfInt EndOfInt clrf STATUS MOVF fsr_temp,w movwf FSR movf pch_temp movwf PCLATH movf status_temp,w movwf STATUS SWAPF w_temp,f SWAPF w_temp,w retfie org 0x0100 main clrf microSec clrf microSec+1 clrf ms50 clrf second ;clrf minute clrf hour banksel OPTION_REG MOVLW B'00000011' MOVWF OPTION_REG CLRF STATUS MOVLW 0X20 MOVWF FSR ClearBank0 clrf INDF incf FSR,f btfss FSR,7 GOTO ClearBank0 movlw .50 movwf minute clrf INTCON BSF INTCON,T0IE BSF INTCON,GIE Loop clrwdt call ClockRun goto Loop ClockRun bcf INTCON,T0IE BANKSEL microSec movlw 0xb0 addwf microSec,f movlw 0x3c skpnc movlw 0x3d addwf microSec+1,f skpnc goto _msTimeout movlw 0x50 addwf microSec,f movlw 0xc3 skpnc movlw 0xc4 addwf microSec+1,f goto _clockExit _msTimeout incf ms50,f movlw .20 xorwf ms50,w ;xorwf ms50,f skpz goto _clockExit clrf ms50 incf second,f movlw .60 xorwf second,w ;xorwf second,f skpz goto _clockExit clrf second incf minute,f movlw .60 xorwf minute,w ;xorwf minute,f skpz goto _clockExit clrf minute incf hour,f movlw .24 xorwf hour,w ;xorwf hour,f skpnz clrf hour _clockExit bsf INTCON,T0IE return end
仿真图
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。