View previous topic :: View next topic |
Author |
Message |
akshaymathur39
Joined: 05 Aug 2008 Posts: 11
|
Error in configuring ADC for PIC18F66J50 |
Posted: Mon Apr 26, 2010 7:31 pm |
|
|
Dear Friends,
I am having some problem in configuring ADC for PIC18F66j50. Here is the code snippet:
Code: | void main()
{
PLLEN = 1;
setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_INTERNAL );
//port_g_pullups (TRUE);
port_e_pullups (TRUE);
//port_g_pullups (TRUE);
//!while(1){
//!output_high(PIN_A0); delay_ms(1000);
//!output_low(PIN_A0); delay_ms(1000);
//!
//!}
set_tris_c(0);
//set_tris_a(1);
glcd_init(ON); // Must initialize the LCD
glcd_text57(1,1,init,1,ON);
delay_ms(1000);
set_adc_channel(0);
delay_ms(100);
while(1){
i = read_adc();
sprintf(rTemp,"%Ld ",i);
rTemp[5]="\0";
glcd_text57(30,30,rTemp,1,ON);
delay_ms(100);
}
} |
This code always shows ADC value as 1023. Only when I short circuit ADC input to ground, it shows 20.
Can anybody please suggest something. Other pins on portA are driving a multiplxer. |
|
|
akshaymathur39
Joined: 05 Aug 2008 Posts: 11
|
|
Posted: Mon Apr 26, 2010 7:52 pm |
|
|
Dear Friends, I tried input through potentiometer and it works perfectly fine. I could see swiping through complete range (0-1023). But when I connect it to LM35, it shows 1023 always. Can anybody please suggest the possible cause and solution.
I tested LM35, and individually it works fine. |
|
|
akshaymathur39
Joined: 05 Aug 2008 Posts: 11
|
|
Posted: Tue Apr 27, 2010 9:51 am |
|
|
Awaiting replies friends...
Please help |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
kongfu1
Joined: 26 Apr 2010 Posts: 56
|
Which version of compiler you are using? |
Posted: Tue Apr 27, 2010 11:38 am |
|
|
Which version of compiler you are using?
akshaymathur39 wrote: | Awaiting replies friends...
Please help |
|
|
|
|