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

Problem in analog comparator in 16f887

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



Joined: 29 May 2009
Posts: 6

View user's profile Send private message

Problem in analog comparator in 16f887
PostPosted: Wed Jun 03, 2009 2:04 am     Reply with quote

I'm using Pic 16f887.
Code:
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_comparator(A0_A1_OUT_ON_A3);

// TODO: USER CODE!!
while(1)
{

if(c1out==1)
  {
   output_high (pin_c7);
  }
else
  {
   output_low (pin_c7);
  }

}

After compiling an error occured: undefined identifier A0_A1_OUT_ON_A3
I'm new to CCS. Pls anyone help me out.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 03, 2009 11:32 am     Reply with quote

Look in the .H file for your PIC, to see the allowable constants for the
CCS functions. Here's the file location:
Quote:
c:\Program Files\picc\Devices\16f887.h
world



Joined: 29 May 2009
Posts: 6

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 12:49 am     Reply with quote

ya i have already looked hex file what constant used for comparator module by seeing that i include then i compiled but once again the same error occured pls help me out.....

thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 1:58 am     Reply with quote

ya i have already looked hex file what constant used for comparator module by
I don't mean the HEX file. I mean the 16F887.H file.


Post your compiler version.
world



Joined: 29 May 2009
Posts: 6

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 2:08 am     Reply with quote

ya i saw 16f887.h file what constant used i changed but also same error occured ......
my compiler version is 4.033


thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 2:19 am     Reply with quote

Quote:
setup_comparator(A0_A1_OUT_ON_A3);
my compiler version is 4.033

I just installed vs. 4.033 and that constant is not in the 16F887.h file.
The constants that set the input and output configuration all begin
with CP1_ or CP2_.

You should use constants from the 16F887.h file. Get rid of that one
and look in the file to find the correct constant.
world



Joined: 29 May 2009
Posts: 6

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 2:29 am     Reply with quote

Quote:

setup comparator(CP1_A0_A1_CP1_OUT_ON_A2);



ya i changed it the same error is occuredd


thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 2:36 am     Reply with quote

You cannot tack constants together with an underscore. That's not C.
They have to be combined with the bitwise 'OR' symbol, which is '|'.
Please learn the C language. Get a book on it.
world



Joined: 29 May 2009
Posts: 6

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 2:50 am     Reply with quote

ok i'll learn it.......

setup_comparator(cp1_a0_a1||cp1_out_on_a2);

is it correct now.......

can u give me good c books for begineer
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 3:15 am     Reply with quote

I told you to use bitwise OR, and gave you the symbol. You changed it to
a Logical OR symbol. You cannot write programs and have them work
if you do things in an inaccurate way.

I don't want to help you any more until you fix this problem, where you
"invent" a solution as you go along.
world



Joined: 29 May 2009
Posts: 6

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 4:47 am     Reply with quote

oh sorry........i typed wrongly it seems. very sorry.........
code built sucessfully not working now
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 04, 2009 4:34 pm     Reply with quote

Quote:
Can u give me good c books for beginner

Threads on books:
http://www.ccsinfo.com/forum/viewtopic.php?t=33272
http://www.ccsinfo.com/forum/viewtopic.php?t=33816

Here are some online C tutorials:
http://www.cs.cf.ac.uk/Dave/C/node4.html
http://cslibrary.stanford.edu/101/EssentialC.pdf

Development tools:
http://www.ccsinfo.com/forum/viewtopic.php?t=26954
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