View previous topic :: View next topic |
Author |
Message |
world
Joined: 29 May 2009 Posts: 6
|
Problem in analog comparator in 16f887 |
Posted: Wed Jun 03, 2009 2:04 am |
|
|
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
|
|
Posted: Wed Jun 03, 2009 11:32 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 12:49 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 1:58 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 2:08 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 2:19 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 2:29 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 2:36 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 2:50 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 3:15 am |
|
|
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
|
|
Posted: Thu Jun 04, 2009 4:47 am |
|
|
oh sorry........i typed wrongly it seems. very sorry.........
code built sucessfully not working now |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|