📄 2.txt
字号:
rlf buff_4, same
rlf temp_e, same
rlf temp_d, same
rlf temp_c, same
rlf temp_b, same
rlf temp_a, same
decfsz count5, same
goto adj_dec
goto done
adj_dec:
movlw temp_e
movwf fsr
call adj_bcd
movlw temp_d
movwf fsr
call adj_bcd
movlw temp_c
movwf fsr
call adj_bcd
movlw temp_b
movwf fsr
call adj_bcd
movlw temp_a
movwf fsr
call adj_bcd
goto bin2bcd_loop
adj_bcd:
movlw h'3'
addwf indf, w
movwf temp_f
btfsc temp_f, 3
movwf indf
movlw h'30'
addwf indf, w
movwf temp_f
btfsc temp_f, 7
movwf indf
return
done:
return
incw_bcd ;increment a packed bcd 8bit freg., enter with data in w
;ex T Scott Dattalo, 20/4/98
movwf scratch
movlw 11111110b
addlw 0x9A+1
subwf scratch,w
rlf scratch,same
btfss status,dc
addlw -0x06
btfss scratch,0
addlw -0x60
rrf scratch,same ;result in w
return
decw_bcd ;decrement a packed bcd freg., enter sub with data in w
;ex T Scott Dattalo, 20/4/98
movwf scratch
movlw 1
subwf scratch,w
rlf scratch,same
btfss status,dc
addlw -0x06
btfss scratch,0
addlw -0x60
rrf scratch,same ;result in w
return
inc_minute_bcd ;incr minutes reg by 1, check for not overflow 60s
movf minute,w
sublw 0x60 ;59hex means 59dec in packed bcd
btfsc status,z
return ;z got set if minutes=59,so don't incr
movf minute,w
call incw_bcd
movwf minute
return
dec_minute_bcd ;decrement minute reg, check for zero underflow
movf minute,w
btfsc status,z
return ;underflow danger, don't decr
call decw_bcd
movwf minute
return
inc_hour_bcd ;incr hours, packed bcd representation
movf hour,w
sublw 0x24
btfsc status,z
return
movf hour,w
call incw_bcd
movwf hour
return
dec_hour_bcd ;decrement hour reg, check for zero underflow
movf hour,w
btfsc status,z
return ;underflow danger, don't decr
call decw_bcd
movwf hour
return
inc_date_bcd ;incr date of month,packed bcd,cheat & assume all months <= 28days
movf date,w
sublw 0x28
btfsc status,z
return
movf date,w
call incw_bcd
movwf date
return
dec_date_bcd ;decrement date reg, check for zero underflow
movf date,w
btfsc status,z
return ;underflow danger, don't decr
call decw_bcd
movwf date
return
inc_month_bcd ;incr month,packed bcd
movf month,w
sublw 0x12
btfsc status,z
return
movf month,w
call incw_bcd
movwf month
return
dec_month_bcd ;decrement date reg, check for zero underflow
movf month,w
btfsc status,z
return ;underflow danger, don't decr
call decw_bcd
movwf month
return
inc_year_bcd ;incr year, packed bcd
movf year,w
sublw 0x99
btfsc status,z
return
movf year,w
call incw_bcd
movwf year
return
dec_year_bcd ;decrement date reg, check for zero underflow
movf year,w
btfsc status,z
return ;underflow danger, don't decr
call decw_bcd
movwf year
return
;*********************************************specific bcd handling routines end
;*********************************************gen. purpose subroutines follow
delay movlw 0x001 ;standard delay routine. increase w value
movwf count1 ; for increased delay
movlw 0x001 ;can set up any delay by calling delay1 (NB!)
movwf count2 ; with pre-set values in count1, 2, 3
movlw 0x020 ;ex Myke Predko, piclist 4 Jan97
movwf count3 ;delay, (no of instructions)=
delay1 decfsz count3,same ;2 + 5*(count3-1) +
goto $-1 ;2 + (5*255 +2+5) * (count2-1) +
decfsz count2,same ;2 + (5*255*256 +2 + 5*255 +2+5) *(count1-1)
goto $-3 ; =
decfsz count1,same ;5(count3-1)+1282(count2-1)+327684(count1-1)+6 &nb
goto $-5 ;
return ;
delay_25us movlw 0x01 ;25uSec delay
movwf count1
movlw 0x01
movwf count2
movlw 0x06
movwf count3
call delay1
return
delay_100us movlw 0x01 ;100uSec delay
movwf count1
movlw 0x01
movwf count2
movlw 0x13
movwf count3
call delay1
return
delay_200us movlw 0x01 ;200uSec delay
movwf count1
movlw 0x01
movwf count2
movlw 0x26
movwf count3
call delay1
return
delay_1ms movlw 0x01 ;1msec delay
movwf count1
movlw 0x01
movwf count2
movlw 0xC8
movwf count3
call delay1
return
delay_100ms movlw 0x01 ;100msec delay
movwf count1
movlw 0x4E
movwf count2
movlw 0x01
movwf count3
call delay1
return
delay_1sec movlw 0x04 ;1 second delay
movwf count1
movlw 0x0E
movwf count2
movlw 0x38
movwf count3
call delay1
return
delay_10sec movlw 0x1F ;10 second delay
movwf count1
movlw 0x85
movwf count2
movlw 0x34
movwf count3
call delay1
return
;********************General purpose 16F84 EEPROM register read/write
;The following `eprom write' routine requires that eeadr @ loc 0x009
;in bank0 contains the address of the eeprom data byte to be loaded.
;The data must be pre-loaded in eedata @ loc 0x008 in bank0
;In addition, the eecon1,wren bit in bank1 regs. must be set before
;calling this routine. Then cleared after using it.
;ie bsf status,rp0 & vice-versa at at finish
; bsf eecon1,wren
; bcf status,rp0
eeprom_wr ;write byte to eeprom loc.
bcf intcon,gie ;make sure ints disabled, work on bank1
btfsc intcon,gie ;to-be-suuuure
goto $-1
bsf status,rp0 ;set to bank 1,see c84 para 7.2
movlw 0x055 ;fairy-godmother value, given by uchip
movwf eecon2 ;-actually for diode pump charging hv cell drives-
movlw 0x0AA ;another fairy-godmother value
movwf eecon2
bsf eecon1,eewr ;set write control bit & begin write
btfsc eecon1,eewr ;poll write control bit until h/w resets it LO
goto $-1 ;write until job done
bcf eecon1,eeif ;must clear this bit, don't know why??
bcf status,rp0 ;bank 0
;enable global ints here, if using them.ie bsf intcon,gie
return
;following routine requires eeadr to be pre-loaded with the eeprom location
;--like a pointer. The contents of the location are returned in eedata reg.
eeprom_rd ;read byte value from eeprom ->w reg
bsf status,rp0 ;bank 1
bsf eecon1,eerd ;ee read
bcf status,rp0 ;bank 0
return
inc_eeprom ;increment eeprom regs 00,01,02
call read_eeprom ;fetch all eeprom vals to 16f84 fregs
incfsz samp_index1,same
goto inc_eeprom1
incfsz samp_index2,same
goto inc_eeprom1
incfsz samp_index3,same
goto inc_eeprom1
inc_eeprom1
movf samp_index1,w
movwf eedata
movlw 0x01
movwf eeadr
bsf status,rp0
bsf eecon1,wren
bcf status,rp0
call eeprom_wr
bsf status,rp0
bcf eecon1,wren
bcf status,rp0
movf samp_index2,w
movwf eedata
movlw 0x02
movwf eeadr
bsf status,rp0
bsf eecon1,wren
bcf status,rp0
call eeprom_wr
bsf status,rp0
bcf eecon1,wren
bcf status,rp0
movf samp_index3,w
movwf eedata
movlw 0x03
movwf eeadr
bsf status,rp0
bsf eecon1,wren
bcf status,rp0
call eeprom_wr
bsf status,rp0
bcf eecon1,wren
bcf status,rp0
return
read_eeprom ;fetch tha values of ALL eeprom 01,02,03
movlw 0x01
movwf eeadr
call eeprom_rd
movf eedata,w
movwf samp_index1
movlw 0x02
movwf eeadr
call eeprom_rd
movf eedata,w
movwf samp_index2
movlw 0x03
movwf eeadr
call eeprom_rd
movf eedata,w
movwf samp_index3
return
;**************************************************end of g.p. subroutines
;**************************************************start of isr
service ;dummy el for isr
retfie
;**************************************************end of isr
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -