CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Error in configuring ADC for PIC18F66J50

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
akshaymathur39



Joined: 05 Aug 2008
Posts: 11

View user's profile Send private message

Error in configuring ADC for PIC18F66J50
PostPosted: Mon Apr 26, 2010 7:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 26, 2010 7:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 27, 2010 9:51 am     Reply with quote

Awaiting replies friends...
Please help
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 27, 2010 11:38 am     Reply with quote

You didn't post a full program. You have tons of commented out code.
You don't show the setup functions for the adc.

There are many posts on the LM35 in the forum archives.
Put LM35 into the search page, here:
http://www.ccsinfo.com/forum/search.php

I got over 40 hits. Here are two of them. I suggest you do the search
and read all the articles:
http://www.ccsinfo.com/forum/viewtopic.php?t=39363
http://www.ccsinfo.com/forum/viewtopic.php?t=31260
kongfu1



Joined: 26 Apr 2010
Posts: 56

View user's profile Send private message

Which version of compiler you are using?
PostPosted: Tue Apr 27, 2010 11:38 am     Reply with quote

Which version of compiler you are using?

akshaymathur39 wrote:
Awaiting replies friends...
Please help
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group