Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help needed for configuring only one analog input pin in PIC 16F877A

Status
Not open for further replies.

amit_kr

New Member
i m using PIC 16F877A for my project ...i want to use only one pin AN0 for analog input ...i m using SourceBoost IDE c compiler to programme the microcontroller....plz help me to configure it ...
ADC configure code for all analog inputs ....
void init_adc(void){
volatile bit adc_on @ ADCON0 . ADON; //AC activate flag

set_bit(adcon1, ADFM); // AD result needs to be right justified
// set_bit(adcon1, PCFG0); // all analog inputs
// set_bit(adcon1, PCFG1); // Vref+ = Vdd
// set_bit(adcon1, PCFG2); // Vref- = Vss

set_bit(adcon0, ADCS1); // Select Tad = 32 * Tosc (this depends on the X-tal here 10 MHz, should work up to 20 MHz)
clear_bit(adcon0, CHS0); // Channel 0
clear_bit(adcon0, CHS1); //
clear_bit(adcon0, CHS2); //
adc_on = 1; // Activate AD module

}
i want to use only one input AN0.....what changes have to made in the code
 
Can't help you with C, but my PIC assembler analogue tutorial explains about the different register settings, in a somewhat more easily understandable fachion than the datasheet - you should be able to get all you need from that!.
 
what compiler are you using? If PIC's C18, there are a lot of prewritten libraries for ADC and all other functions that are quite handy
 
Status
Not open for further replies.

Latest threads

Back
Top