Hi all,
I have the following assembly program which is an ADC. It is monitoring the analogue input at AN0 and output its respective binary value to port D.
Now i want to save the analogue input value to Register X, compare it to a value in register Y and if the value of Resister X is smaller, PORT B,0 will go to high, else it will remain low.
Can someone help me in doing this please.
BTW im using an 18F4550 PIC micro-controller.
Thanks in advance...
I have the following assembly program which is an ADC. It is monitoring the analogue input at AN0 and output its respective binary value to port D.
Code:
;REGISTER DECLERATIONS
REG1 EQU 60H ;;HEARE WE ARE NAMING THE GENERAL PURPOSE REGISTORS
ADC_H EQU 61H
ADC_L EQU 62H
COUNTER EQU 63H
ORG 0000H
ORG 0004H
ORG 00008H ;HIGH PRIORITY VECTOR
ORG 000018H ;LOW PRIORITY INTERRUPT VECTOR
ORG 0020H
;ALL INTIALIZATION HERE OF ALL PORTS AND PERIPHERALS HERE
MOVLW B'00001110' ;;SET RAO AS AN0
MOVWF ADCON1
MOVLW B'00101100' ;LEFT JUSTIFIED
MOVWF ADCON2 ;;ACQUSITION TIME
;;12TAD
;;CLOCK FREQ FOSC/4
MOVLW B'00000001' ;;CHONNEL 0
MOVWF ADCON0 ;;ADC ON
MOVLW B'111'
MOVWF TRISE
MOVLW B'111111' ;;DECLARING PORT AS INPUT
MOVWF TRISA
CLRF PORTD
CLRF TRISD
;START MAIN PROGRAM HERE
MAIN
CALL ACQ_DELAY ;CALL DELAY
BSF ADCON0,1 ;SET ADCON0 bit 1 high
LINE1
BTFSC ADCON0,1 ;check if ADCON0 bit 1 if clear,if yes skip the next instruction
BRA LINE1
MOVFF ADRESH, ADC_H ;copying the value from ARESH into ADC_H
MOVFF ADRESH, PORTD ;copying the value from ARESH into portD
MOVFF ADRESL, ADC_L ;copying the value from ARESH into ADC_L
GOTO MAIN
ACQ_DELAY
MOVLW .3
MOVWF COUNTER
ACQ1
DECFSZ COUNTER
BRA ACQ1
RETURN
Now i want to save the analogue input value to Register X, compare it to a value in register Y and if the value of Resister X is smaller, PORT B,0 will go to high, else it will remain low.
Can someone help me in doing this please.
BTW im using an 18F4550 PIC micro-controller.
Thanks in advance...