You can't do movf ADRESH,PEAK This is not a valid instruction and should have produced at least a warning.
To get the peak value you need to do a subtraction like this,
You also need to clr Peak before your Main loop.
Mike.
To get the peak value you need to do a subtraction like this,
Code:
movfw ADRESH ;get ADC result
subwf Peak,W ;do Peak-ADC
btfss STATUS,C ;C set if ADC>Peak
goto DoneMax ;not higher
movfw ADRESH ;is higher
movwf Peak ;so copy to peak
DoneMax
Mike.