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 CCS Technical Support

kinda confused about the #DEVICE statement

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



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

kinda confused about the #DEVICE statement
PostPosted: Wed May 14, 2008 5:22 pm     Reply with quote

I need to tell my 16F886 that i want to read 10 bit data - as the default is to report the ADC at only 8 of its 10 native bits

so i added the #device statement at the head of a program that uses the ADC to tell it use adc=10 bits

problem is that no matter how i try to do it my
ver 4.066 compiler says

" cannot change device this far into program "

at line #2 - first compiled line ???
?
( i have stripped ALL the rest of the code - to make is show more clearly and heres is the smallest fragment that shows the problem )
If i comment out the #device line - the rest of the rather extensive program this frag is lifted from - works fine what the HECK is this dumb guy doing wrong with the #device statement ???
not being able to switch on 10 bit adc reading is killing me
//
#device PIC16F886 *=16 ADC=10
#include <16f886.h>
#include <stdlib.h>
#FUSES NOPROTECT,INTRC,NOWDT,NOMCLR,NODEBUG,NOLVP,NOIESO,NOFCMEN,PUT,NOWRT,NOFCMEN,NOBROWNOUT
main() {
for (;;) {
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 14, 2008 5:28 pm     Reply with quote

Do it like this, in this order:
Quote:
#include <16F886.h>
#device *=16 ADC=10
#FUSES NOPROTECT,INTRC,NOWDT,NOMCLR,NODEBUG,NOLVP, etc.
#include <stdlib.h>
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