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

hi everyone from a new user :)

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



Joined: 14 Jul 2007
Posts: 38

View user's profile Send private message

hi everyone from a new user :)
PostPosted: Sat Jul 14, 2007 7:07 am     Reply with quote

dear friend ,this is my first visit to this forum. i would like to ask a question to be answered . ı was trying to read a pot at RA0(analog input) and display the result on a LCD. ı made tehe adc set to 10 bit. however the max value that ı read is 255. so how could i read 10 bit adc result and display on to LCD?

thank you ...
ferkar



Joined: 14 Jul 2007
Posts: 38

View user's profile Send private message

10 bit adc problem?
PostPosted: Sat Jul 14, 2007 9:11 am     Reply with quote

ı thougt about my problem again. and now ı am trying to find that what is the problem exactly.
if ı made the pic16f877 adc setc correctly perhaps LCD could not show 10bit data without a special set. i looked the help file and the examples all shows that 8bit data.

ı am really confused about it.
any help?
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Sat Jul 14, 2007 9:47 am     Reply with quote

use the preprocessor directive
#device adc=10

and store the value in a 16 bit variable (long or int16) also use the corresponding printf format parameter for the LCD, ...or whatever is your output routine.
ferkar



Joined: 14 Jul 2007
Posts: 38

View user's profile Send private message

thak you for help but...
PostPosted: Sat Jul 14, 2007 9:59 am     Reply with quote

libor ,
ı tried your advice but in that case compiler gives an error like that
" can not change device type this far into the code"

note:my ccs compilerversion is 3.249
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Sat Jul 14, 2007 10:14 am     Reply with quote

" can not change device type this far into the code"

Then try to change device type not that far in the code :-) Move it to the beginning of the code.
But the problem is, the header file xxxx.h also has a #device line. So I usually place the #device after the #include.
Or you can also edit the one in the header file to include the ADC=10 setiing.
ferkar



Joined: 14 Jul 2007
Posts: 38

View user's profile Send private message

sorry but it did not work
PostPosted: Sat Jul 14, 2007 10:45 am     Reply with quote

added the "device adc=10 " line after include line in the 16f877a header file. the lcd still shows 8 bit value (max 255). here is code that i use maybe it is helpful for you to give an advice:

for(;;)
{

int16 olc,setd;

long int hata;
long int sur;
int kp;
int ki;
long sur_P;
long sur_I;
long al;
long hata_es;
int i;


lcd_init() ;

printf(lcd_putc, "set = %Lu",setd);


set_adc_channel(0);// set

setd=read_adc();
delay_us(25);
PCM programmer



Joined: 06 Sep 2003
Posts: 20217

View user's profile Send private message

PostPosted: Sat Jul 14, 2007 11:32 am     Reply with quote

See the demo program in this post:
http://www.ccsinfo.com/forum/viewtopic.php?t=28842&start=7
Ignore the comments about vs. 3.163. You should be able to use
the program without any changes, with vs. 3.249.
ferkar



Joined: 14 Jul 2007
Posts: 38

View user's profile Send private message

thank you so much:)
PostPosted: Sun Jul 15, 2007 9:20 am     Reply with quote

pcm programmer ,
i made that changes and code worked as ı wish.
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