list p=10F222 ; list directive to define processor
#include <p10F222.inc> ; processor specific variable definitions
__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOSCFS_4MHZ
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
UDATA
reg1 res 1 1st reference voltage value
reg2 res 1 2nd reference voltage value
calreg res 1
cflag res 1 conditional flag
counter1 res 1
counter2 res 1
#define PORT_MASK b'111000' ;make GP2 an output, but GP0, GP1 is also made as an output to avoid short circuit, GP3 as Input. It is mapped according to GPIO Pins
#define MAXLIMIT 0xC0 ;maximum limit for voltage
#define LOWLIMIT 0x01 ;lowest limit for voltage
;**********************************************************************
RESET_VECTOR CODE 0x1FF ; processor reset vector
res 1
; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.
MAIN CODE 0x000
movwf OSCCAL ; update register with factory cal value
start
;Initial configuration
movlw PORT_MASK ; Configure GP2 as an output
tris GPIO
movlw b'00000' ; set GP2 Low for output, frm 0V
movwf GPIO
movlw b'10000100' ; Configure ADC, AN1 analog , Conversion OFF GO/DONE = 0, ADON ::::Configuring Input port and ADC configuration
movwf ADCON0 ; AN1 selected
bcf cflag,0 ; initially conditional flag should be '0'
movlw b'00100' ;set the flag for output Logical HIGH, to check output
movwf GPIO