>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >Sent: 18 September 2006 00:40 >To: Microcontroller discussion list - Public. >Subject: [PIC] Problem with PIC12F675 A/D conversion > > >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); You are enabling the A/D interrupt, but then you are polling the interrupt flag which doesn't make sense. You only enable the interrupt if you want to handle completed conversions within your interrupt handler. If instead you are polling the ADIF flag to wait for A/Dconversions then make sure you clear ADIE. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist