A2D
start_sampling
bsf ADCON0,1 ;start conversion
btfsc ADCON0,1
goto $-2
incf Avg_cnt ;sample counter
;add 32 samples
movf ADRESL,w
addwf read1_low,f
btfsc STATUS,C
incf read1_high
movf ADRESH,w
addwf read1_high,f
movlw .32
subwf Avg_cnt,w
btfss STATUS,Z
goto start_sampling
clrf Avg_cnt
;divide by 32
bcf STATUS,C
rrcf read1_high
rrcf read1_low ;/2
bcf STATUS,C
rrcf read1_high
rrcf read1_low ;/4
bcf STATUS,C
rrcf read1_high
rrcf read1_low ;/8
bcf STATUS,C
rrcf read1_high
rrcf read1_low ;/16
bcf STATUS,C
rrcf read1_high
rrcf read1_low ;/32