Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] NEED HELP for ADC programming

Status
Not open for further replies.

Chullaa

Advanced Member level 4
Full Member level 1
Joined
Aug 27, 2010
Messages
113
Helped
17
Reputation
34
Reaction score
17
Trophy points
1,298
Activity points
2,019
Hi guys
i am very much biggner! Well i've started working with 16F877 adc modules..
bt i am confused abt the programming. how to set range of input from 0 to +5V and setting resolution...bla bla
could anyone please send me some simple programes in C. I am using PICC complier and Proteus 7.4 for circuit operation.
my work is attached!


long value;
void main()
{
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(1);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);

TRISB=0x00;
adcon0=0x81;
adcon1=0xCE;

// TODO: USER CODE!!
while(1)
{
set_adc_channel(0);
delay_ms(100);
PORTB = read_adc();

}

}
 

Hi guys
i am very much biggner! Well i've started working with 16F877 adc modules..
bt i am confused abt the programming. how to set range of input from 0 to +5V and setting resolution...bla bla
could anyone please send me some simple programes in C. I am using PICC complier and Proteus 7.4 for circuit operation.
my work is attached!


long value;
void main()
{
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(1);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);

TRISB=0x00;
adcon0=0x81;
adcon1=0xCE;

// TODO: USER CODE!!
while(1)
{
set_adc_channel(0);
delay_ms(100);
PORTB = read_adc();

}

}

Hi,

Please connect VRef Pin to 5v if you want to adc input 0 to 5 v, if u want adc input 0 to 3v then connect Vref pin to 3v.
 

thanks Raj
i did that. but dint worked. Than i changed
PORTB = read_adc(); TO PORTB = ADRESL;
it worked. Wonder y
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top