📄 readvr.asm
字号:
;==========================================================================
; File Name : readvr.asm
;
; Rev: Date: Author: Reason:
; 1.00 dd-mm-yy nnnnnnnnnnn rrrrrrrrrrrrrrrrrr
;==========================================================================
;------------------------------------------------------------
; Name : read_vr
; Parm : nil
; Retn :
; Desc :
;------------------------------------------------------------
read_vr:
bsf STATUS,RP0
movlw ADC_ANA_IN
movwf ADCON1
bcf STATUS,RP0
bsf ADCON0,ADON ; turn on ADC, start sampling
bcf ADCON0,CHS1
bcf ADCON0,CHS0 ; channel 0
call read_chn
movwf xaxis_val
bsf ADCON0,CHS0 ; channel 1
call read_chn
movwf yaxis_val
bsf ADCON0,CHS1
bcf ADCON0,CHS0 ; channel 2
call read_chn
movwf zaxis_val
bsf ADCON0,CHS0 ; channel 3
call read_chn
movwf raxis_val
bsf STATUS,RP0
movlw ADC_DIG_IN
movwf ADCON1
bcf STATUS,RP0
bcf ADCON0,ADON ; turn off ADC
return
;------------------------------------------------------------
; Name : read_chn
; Parm : nil
; Retn : W: A/D convertor value
; Desc : read A/D convertor of current analogue channel.
;------------------------------------------------------------
read_chn:
bcf f_siointr
movlw 0x20
movwf delay0
rdch_dly: ; sample and hold delay
call p_timer
btfsc f_siointr
goto read_chn
decfsz delay0,F
goto rdch_dly
bsf ADCON0,GO ; start A/D conversion
rdch_conv: ; wait for A/D complete
call p_timer
btfsc ADCON0,GO
goto rdch_conv
btfsc f_siointr
goto read_chn
movf ADRES,W ; return result
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -