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 The second one is: set the AD channels and device operating frequency, turn ON the AD module, turn ON the interrupt from the PEIE&GIE&ADIE bits and inside the interrupt routine poll the ADIF. Maybe is just because you forgot to turn on the PEIE&GIE see page 62 of the DS41190C. I don't know your compiler nor C. regards, Vasile On 9/18/06, Shawn Wilton wrote: > I'm attempting to use a polling technique to read the a/d converter on this > 12F675, but I'm having trouble getting the chip to perform the conversion. > > I'm using the freeware version of the BoostC compiler. Latest version. > > My code for setting up the A/D: > > > //Setting up the TriState Register > trisio = 010100b; > //Enable pull-ups if we want them > //set_bit(option_reg, NOT_GPPU); > > /******** > Setup the ADC > ********/ > //Right justified > set_bit(adcon0, ADFM); > > //Voltage reference = Vdd > clear_bit(adcon0, VCFG); > > //Set A/D ports 2 and 3 for analog inputs > set_bit(ansel, ANS2); > set_bit(ansel, ANS3); > > //Use Frc instead > set_bit(ansel, ADCS0); > set_bit(ansel, ADCS1); > clear_bit(ansel, ADCS2); > > //Enable the A/D interrupt > set_bit(pie1, ADIE); > > //Turn on the ADC > adc_on = 1; > > > Then the code used to poll the ADC: > > unsigned int result = 0; > unsigned int high = 0; > unsigned int low = 0; > > //Set the ADC Channel > adcon0 |= channel << 2; > > //Begin a conversion > adc_go = 1; // bit 1 of adcon0 > > //Begin the conversion and block until it's complete > //while(test_bit(adcon0, 1)) > while(!test_bit(pir1, ADIF)) > { > set_bit(gpio, LED_PIN); > } > > //Clear the interrupt flag > clear_bit(pir1, ADIF); > > //Convert to 16 bit vars so we can shift properly > high = ADRESH; > low = ADRESL; > > //Shift the upper bits 8 up and append to the lower bits > return ((high << 8) | (low)); > > > I'm primarily an Atmel man, so I'm scratching my head wondering why the > conversion never takes place. According to the d/s, the adcon0, bit 1 > should be cleared when the conversion is complete, and the ADIF bit should > be set when the conversion is complete. I have tried both methods and > neither are working out for me. > > If I have failed to include any relevant details, lmk. > > -- > > 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 > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist