I'll give that a shot Vasile, but it looks like what I'm already doing. On 9/18/06, Vasile Surducan wrote: > > This is a jal procedure for reading the AD module of the 12F675. I > think is self explanatory. Try to convert it in C and will (probably) > work. > > const bit ref_extern = high > const bit ref_vdd = low > const bit left_justify = high > const bit right_justify = low > > procedure one_ch_ad_read ( byte in channel, bit in ref, bit in justify ) > is > ; result in adresh and adresl, > ; channel = 0...3, ref=high means external reference, justify=high > means left justify > var byte local > if channel == 0 then local = 0b_0000_0001 > elsif channel == 1 then local = 0b_0000_0010 > elsif channel == 2 then local = 0b_0000_0100 > elsif channel == 3 then local = 0b_0000_1000 > end if > asm bsf _rp0 ; set bank1 > ansel = ( 0b_0001_0000 + local ) ; fosc/8, internal 4MHz clock > asm bcf _rp0 ; set bank0 > channel = channel << 2 > adcon0 = ( 0 + channel ) > if ref then > asm bsf vcfg > else asm bcf vcfg > end if > if justify then > asm bcf adfm > else asm bsf adfm > end if > > asm bsf adon ; supply the ad module > delay_10uS ( 1 ) ; wait the sampling time > asm bsf go_done ; start the conversion > while go_done loop end loop ; wait for ad completion > end procedure > > usage: > one_ch_ad_read ( 0, ref_vdd, left_justify ) > read the adresh and adresl > > > On 9/18/06, Shawn Wilton wrote: > > Yeah, I have tried this and the conversion never returns. I block on > the > > poll of the Go\Not Done bit and it never changes back to a zero > indicating a > > successful conversion. > > > > > > On 9/18/06, Vasile Surducan wrote: > > > > > > There are two wais (at least) of using the AD module in PIC > > > microcontrollers. > > > First one is: set the AD channels and device operating frequency, turn > > > on the AD module, wait 20uS for aquisition time and wait untill the > > > GO/DONE bit is changing > > -- > > http://www.piclist.com PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- Shawn Wilton (b9 Systems) http://b9Systems.com <- New web page -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist