re:4楼 以下是我的程序,硬件也很简单,使用内部复位、内部RC振荡。 LIST P=12C509 #include <p12c509.inc>
msec equ 10h sec equ 11h min equ 12h
org 00h start1 btfss STATUS,NOT_PD ;检测是否上电复位 goto loop btfss STATUS,NOT_TO goto loop int movlw 0x07 ;上电复位,清07H~1FHRAM movwf FSR int0 clrf INDF incf FSR,1 movlw 0x1f subwf FSR,0 btfss STATUS,C goto int0
loop movlw 0x03 ;设置option option clrf TMR0 ;开始计时 loop0 movlw 0xf9 ;250 subwf TMR0,0 btfss STATUS,C goto loop0 ;不到4ms,等待 movlw 0x03 nop nop nop nop nop nop option clrf TMR0 clrwdt incf msec,1 movlw 0xfa subwf msec,0 btfss STATUS,C goto loop0 ;不到1S(250个4ms) clrf msec incf sec,1 ;到1S,sec加1 movlw 0x3c subwf sec,0 btfss STATUS,C goto pdout clrf sec incf min,1 ;够60S,min加1 pdout movlw 0x0f subwf min,0 btfss STATUS,C goto no_15min ;不到15min movlw 0x0f ;到15min, movwf min
clrw tris 6 bsf GPIO,1 bcf GPIO,2 btfss GPIO,0 goto zhi1 bcf GPIO,0 goto to_loop0 zhi1 bsf GPIO,0 goto to_loop0
no_15min clrw tris 6 bcf GPIO,1 bsf GPIO,2 btfss GPIO,0 goto zhi1_1 bcf GPIO,0 goto to_loop0 zhi1_1 bsf GPIO,0
to_loop0 goto loop0 end
re5楼:
你说的现象我也遇到过,就是用软件仿真上面的程序时,在goto loop0处总是转到start1,后来把movlw 0x03 option改为movlw 0x83 option就没问题了,我也不知道为什么会这样.
|