On Thu, Jul 22, 2010 at 8:50 AM, Joep Suijs <[email protected]> wrote:
> Hi Seb, > > The latest app however took me a > bit more time since there was no ADC sample for my chip (16f877) and > it took me some time to figure out how to setup ADC on this chip. In > the process I noticed there are no test files, so no samples are > generated. > Hi Joep, I hope you will not be upset by posting here a simple routine (low res) which is using the ADC for this PIC, but which probably has no relation with jallib ADC library: procedure adc_8 ( byte in PCFG, byte in channel, byte out adcL ) is begin ADCON0 = 0 -- Stop ADC ADCON1 = ( PCFG & 0x0F ) -- PCFG bits and left justified ADCON1_ADFM = low ADCON0 = 0x80 | ( ( channel & 0x07 ) << 3 ) -- channel and clock ADCON0_ADON = high -- turn on ADC module delay_10uS( 2 ) -- wait Tacq ADCON0_GO = high -- Start conversion while ADCON0_GO loop end loop ADCON0 = 0 -- Stop ADC adcL = ADRESH end procedure I've noticed, (just as a paranthesis) that PIC 18 need only 2.5uS for Tacq... Vasile example of use: adc_8 (0b_0000_1110, 0, mains_value) ; left justified, A0 input all other digital IO, read A0 and store it in mains_value -- 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.
