Reading ADC on PIC16F877A

Thread Starter

MOHD AZUARI BIN MUSTAPHA

Joined Jan 12, 2015
1
Hello,
I'm using PIC 16f877a, my problem is how to write program that need a range for ADC
for exampe:
100<x>120 to turn led_1 on
1020<x>150 to turn led_2 on

x = adresh value

can anyone help me
 

joeyd999

Joined Jun 6, 2011
5,287
Well, you could start with a compare function:

Code:
;**************************************************
;** COMP16 -- Compare 2 sixteen bit numbers      **
;**   if oper11:0 = oper01:0, Z=1, C=1, Plus     **
;**   if oper11:0 > oper01:0, Z=0, C=1, Plus     **
;**   if oper11:0 < oper01:0, Z=0, C=0, Minus    **
;**************************************************

comp16	movfw	oper01
	subwf	oper11,w
	btfss	status,z
	return

	movfw	oper00
	subwf	oper10,w
	return
 
Top