📄 pmeter.asm
字号:
movwf ACCaLO
call D_divS ; result in ACCb pwr=(s/100)*10 simple avg.
call B2_BCD ; ACCd,ACCa = B2_BCD(ACCb)
call AYDISP2 ; display low 4bytes
goto mode0_done
mode0_done
goto main_loop
Mode1
;------------------------------------------------------
; Mode1 = Energy Accumulation Measurement
;------------------------------------------------------
movlw .13 ; waiting 10ms to prevent over display
call DELAY
movlw 0x80 ; clear all but arrow which we will flash
andwf AY_DP
bsf ay_arr_flash_slow ; MODE1 = FLASH ARROW SLOW
btfsc no_d1 ; if no_d1 bit is set goto d2_or_d3
goto d2_or_d3
;
; d1 calc - just display low part of 24-bit e register
;
movf eLO,W
movwf ACCbLO
movf eMED,W
movwf ACCbHI
call B2_BCD ; ACCd,ACCa = B2_BCD(ACCb)
movf ACCdLO,w
btfsc _z ; if if 5th nibble zero then d1, else
goto disp_d1
bsf no_d1 ; need to set flag to insure no more d1
goto d2_or_d3
disp_d1
bcf ay_dp3
bsf ay_dp4 ; want 0.000 in display
call AYDISP2 ; display low 4bytes
goto mode1_done
d2_or_d3
;
; d2 calc = (e>>8)/4
;
movf eMED,W ;ACCb is numerator
movwf ACCbLO
movf eHI,W
movwf ACCbHI
clrf ACCaHI ;ACCa is denominator
movlw .04
movwf ACCaLO
call D_divS ;result in ACCb d2=(e>>8)/4
call B2_BCD ; ACCd,ACCa = B2_BCD(ACCb)
btfsc no_d2 ; if no_d2 bit is set goto d3
goto disp_d3
movf ACCdLO,w
btfsc _z ; if if 5th nibble zero then d2, else
goto disp_d2
bsf no_d2 ; need to set flag to insure no more d2
goto disp_d3
;
; disp_d2 displays 4 low digits as 0.000
;
disp_d2
bcf ay_dp3
bsf ay_dp4 ; want 0.000 in display
call AYDISP2 ; display low 4bytes
goto mode1_done
;
; disp_d2 displays 4 high digits as 00.00
;
disp_d3
bsf ay_dp3 ; want 00.00 in display
bcf ay_dp4 ;
call AYDISP1 ; display high 4bytes
goto mode1_done
mode1_done
goto main_loop
Mode2
;------------------------------------------------------
; Mode2 = Avg Energy Accumulation Measurement
;------------------------------------------------------
movlw .13 ; Insure TIC has changed by waiting 10ms
call DELAY
movlw 0x80 ; clear all but arrow which we will flash
andwf AY_DP
bsf ay_arr_flash_fast
; movlw 0x14
; call AYMSG
call GET_AD
movf PWR,W
movwf ACCaLO
movf MODE,W
movwf ACCaHI
call AYDISP2
goto main_loop
Mode3
;------------------------------------------------------
; Mode3 = Time since Reset
;------------------------------------------------------
movlw .13 ; Prevent over-display
call DELAY
movf MIN,w
btfss _z
goto min_sec_display
bsf ay_l ; non-flashing colon
bcf ay_l_flash_slow
bcf ay_arr
bcf ay_arr_flash_slow
bcf ay_arr_flash_fast
clrf ACCbHI ; Initialially display sec and tics
movf SEC,w
movwf ACCbLO
call B2_BCD
movf ACCaLO,w
movwf AY_TEMP ; save BCD SECS
clrf ACCbHI
movf TIC,w
movwf ACCbLO
call B2_BCD
movf AY_TEMP,w
movwf ACCaHI ; restore BCD SECS
call AYDISP2 ; display low 4bytes
goto main_loop
min_sec_display
bsf ay_l_flash_slow
bcf ay_arr
bcf ay_arr_flash_slow
bcf ay_arr_flash_fast
clrf ACCbHI
movf MIN,w
movwf ACCbLO
call B2_BCD
movf ACCaLO,w
movwf AY_TEMP ; save BCD MIN
clrf ACCbHI
movf SEC,w
movwf ACCbLO
call B2_BCD
movf AY_TEMP,w
movwf ACCaHI ; restore BCD MIN
call AYDISP2 ; display low 4bytes
mode3_done
goto main_loop
;************************END OF MAIN LOOP****************************
;********************************************************************
; INT_SERVICE
; This Handler routes interrupts to the correct ISR.
; ON ENTRY:
; RETURNS:
; REGS DESTROYED:
;********************************************************************
INT_SERVICE
;
; Push Status and W register to preserve bkground processing
;
movwf SAV_W
movf _status, W
movwf SAV_ST
;
; Determine Cause of Interrupt and Service
;
btfsc _rtif ; RTCC INTERRUPT?
call RTCC_SERVICE
;
; Pop Status and W register to preserve bkground processing
;
movf SAV_ST,W
movwf _status
movf SAV_W,W
retfie ; Enable Global INT and Return
;********************************************************************
; RTCC_SERVICE
; With the prescaler set to divide by 256, the
; rtcc interrupts at a 10ms period.
; ON ENTRY:
; RETURNS:
; REGS DESTROYED:
;********************************************************************
RTCC_SERVICE
bcf _rtif ; Clear RTCC Interrupt Flag
; 10ms=10,000us
; 10,000 /256 = 39.025
movlw .217 ; 256-39 = 217, 39counts=10ms
movwf _rtcc ; restore timer value for next interval
;------------------------------------------------------
; AY LCD Direct Drive Backplane Code
;------------------------------------------------------
btfss ay_bp
goto set_bp
bcf ay_bp ; bp=low
btfss ay_arr
goto arr_lo ; arr=lo=off if bp=lo
goto arr_hi ; arr=hi=on if bp=lo
set_bp
bsf ay_bp ; bp=high
btfss ay_arr
goto arr_hi ; arr=hi=off if bp=hi
goto arr_lo ; arr=lo=on if bp=hi
arr_lo
bcf ay_arr_out
goto arrow_done
arr_hi
bsf ay_arr_out
arrow_done
;------------------------------------------------------
; Maintain Timer Counters
;------------------------------------------------------
movf TIC,w
sublw .100
btfsc _z
goto TIC_ROLL
incf TIC
goto ROLLOVER_END
TIC_ROLL
bsf 1s_flag ; flag used by background
bsf 1s_flag2 ; flag used by background
clrf TIC
incf SEC
movf SEC,w
sublw .60 ; Now check for SEC rollover
btfsc _z
goto SEC_ROLL
goto ROLLOVER_END
SEC_ROLL
clrf SEC
incf MIN
ROLLOVER_END
;------------------------------------------------------
; Check on 250ms and 500ms periodic tasks
;------------------------------------------------------
movf TIC,w
btfsc _z
goto per_500
movf TIC,w
sublw .25
btfsc _z
goto per_250
movf TIC,w
sublw .50
btfsc _z
goto per_500
movf TIC,w
sublw .75
btfsc _z
goto per_250
goto per_250_over
;------------------------------------------------------
; 500ms Periodic Processing Here
;------------------------------------------------------
per_500
bsf 500ms_flag ; flag used by background
btfss ay_l_flash_slow
goto slow_flash_over
movlw 0x08 ; mask for bit3 of AY_DP
xorwf AY_DP ; toggle colon
slow_flash_over
btfss ay_arr_flash_slow
goto slow_arr_flash_over
movlw 0x80 ; mask for bit7 of AY_DP
xorwf AY_DP ; toggle arrow
slow_arr_flash_over
; NOTE: 500ms code should 'fall through' to 250ms code.
;------------------------------------------------------
; 250ms Periodic Processing Here
;------------------------------------------------------
per_250
btfss ay_arr_flash_fast
goto fast_arr_flash_over
movlw 0x80 ; mask for bit7 of AY_DP
xorwf AY_DP ; toggle arrow
fast_arr_flash_over
per_250_over
;------------------------------------------------------
; Get power value from A/D
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -