var word measure
enable_digital_io()  -- disable analog I/O (if any)
-- now configure ADC
const bit ADC_HIGH_RESOLUTION = true -- 10bit resolution
const byte ADC_NVREF = 0 -- no voltage reference
-- unfortunately, 16f877 don't have independent adc channels :(
const byte ADC_NCHANNEL = 1 -- that would be RA0

include adc
adc_init()

measure = adc_read(0) -- read on analog RA0
-- so, you have all digital, and one analog, have fun

Vasi(funlw65)


On Jan 8, 4:06 am, "Wayne <[email protected]>" <[email protected]>
wrote:
> William wrote:
> > On Jan 7, 7:10 pm, "Wayne <[email protected]>" <[email protected]>
> > wrote:
> >> Make sure you don't call
> >> enable_digital_io()
> >> after this adc_init(), since this disables the use of ADC.
>
> > Right, I meant to say, I'm not sure how to do it with JALLIB.
>
> > -- Eur's routine to read the A/D
> > var word analog
>
> > procedure get_analog is
> >    ADCON0_NDONE = true
> >    while ADCON0_NDONE loop end loop
> >    analog = word(ADRESH) << 8
> >    analog = analog + word(ADRESL)
> > end procedure
>
> > ADCON0 = 0b01_000_001
> > ADCON1 = 0b10_00_1110
>
> > forever loop
> >    get_analog()
> >    -- display on lcd
> > end loop
>
> > William
>
> I just finished re-reading the Joep & Toon Tutorial.  They explained the
> answer to my question.  ie to use the analog pins as digital IO
> you have to disable them using the enable_digital_io().  what I had
> read, but didn't remember, was that the non analog pins are usable any
> way 'without' using the enable_digital_io() call.
>
> So in my case I just have to use a digital pin for the LCD and an analog
> pin for the adc and never call enable_digital_io().
>
> Thank you Joep & Toon.  Your Tutorial has helped me yet again.
>
> Regards
>
> Wayne
-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.


Reply via email to