PDA

View Full Version : Serial output problems...



jesterhoz
- 2nd March 2005, 02:31
Hello all,

We are trying to do a simple A/D conversion using a Pic16f877a chip. Our code is as follows:

------------------------------------------

Include "modedefs.bas"

DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50

adcVar var byte ' Create variable to store result
Init:
'PortB=$00
TRISB = %00000000
TRISA = %11111111
ADCON1 = %10000010

main:
ADCIN 0, adcVar ' Read channel 0, store in adcVar

serout2 portC.6, 16468, [ adcVar ] '16468 = N9600
Pause 100
goto main

-----------------------------------------

But, for some reason, our output is not varying along with the analog input from the potentiometer we are reading from.

Anyone have any ideas?

Thanks,

Trevor

Bruce
- 2nd March 2005, 02:39
Left justify for 8-bit A/D. ADCON1 = %00000010.