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

Compiler say "Undefined identifier"

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



Joined: 12 Nov 2007
Posts: 37

View user's profile Send private message

Compiler say "Undefined identifier"
PostPosted: Tue Jan 24, 2012 2:39 am     Reply with quote

Complier 4.099
PIC 16F616

#include <16F616.h>
#device adc=8
//
#FUSES WDT //Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES NOPROTECT //No code protected from reads
#FUSES IOSC8 //INTOSC speed 8MHz
#FUSES NOMCLR //No master Clear pin enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES PUT //Power Up Timer
//
#use delay(clock=8000000)
#use fast_io(a)
#use fast_io(c)
//
#bit ECCPAS0 = 0x17.4 // Auto shutdown control bit (ECCPAS-reg)
#bit ECCPASE = 0x17.7 // PWM start/stop control bit (ECCPAS-reg)
.
.
#include "Aliohjelmat.h" //Subroutine
void main()
{
set_tris_a(0b111011); // 1=input, 0=output.
set_tris_c(0b001111);
//
output_float(PIN_C0);
output_float(PIN_C1);
output_float(PIN_C2);

setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
//
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_wdt(WDT_2304MS);
restart_wdt();
setup_timer_1(T1_DISABLED);
//
setup_timer_2(T2_DIV_BY_1,99,1);
ECCPAS0 = 1; // < ------ This is OK.
ECCPASE = 1; // < ------ This is OK.
set_pwm1_duty(0L);
setup_ccp1(CCP_PWM | CCP_SHUTDOWN_ON_COMP1);
//
setup_vref(VREF_HIGH|REFERENSSI);
setup_comparator(CP1_C3_VREF | CP1_OUT_ON_A2 | CP1_INVERT);
while(1)
{
}
}
.
.
void eteen_kiihdytys() <- Subroutine
{
restart_wdt();
nopeus = NOPEUS_START;
kiihdytys_nopeus = NOPEUS_OK - 20;
set_pwm1_duty(nopeus);
ECCPAS0 = 1; < ----- Undefined identifier ECCPAS0 !?!?!?!?!
ECCPASE = 0; < ------ This is OK.
delay_ms(10);
while((!ECCPASE) && (nopeus < kiihdytys_nopeus))
{
restart_wdt();
nopeus = nopeus+20;
set_pwm1_duty(nopeus);
delay_ms(10);
if(!input(PIN_C2)) suunta = 20;
if(suunta == 20) if(input(PIN_C2)) suunta = 30;
}
if(!ECCPASE) set_pwm1_duty(NOPEUS_OK);
kahva_old = kahva;
return;
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Jan 24, 2012 5:18 am     Reply with quote

This normally means there is a syntax error several lines _earlier_.
The compiler flags an error, when what it is trying to do becomes impossible. Unfortunately the root cause, can often be something else many lines before.
Since you have cut and carved the stuff in front of it, there is no way we can help. However (for example), you will find people having faults like this, often having something missing like a bracket, semi-colon, or comma even sometimes in something like an include file, hundreds of lines earlier....

Best Wishes
jjude



Joined: 12 Nov 2007
Posts: 37

View user's profile Send private message

PostPosted: Tue Jan 24, 2012 5:45 am     Reply with quote

Ttelmah wrote:
Since you have cut and carved the stuff in front of it, there is no way we can help. However (for example), you will find people having faults like this, often having something missing like a bracket, semi-colon, or comma even sometimes in something like an include file, hundreds of lines earlier....

If I only to add a line of subroutine #bit ECCPAS0 = 0x17.4 compiler is OK ?
Code:

void eteen_kiihdytys()  // <- Subroutine
{
#bit ECCPAS0 = 0x17.4
restart_wdt();
nopeus = NOPEUS_START;
kiihdytys_nopeus = NOPEUS_OK - 20;
set_pwm1_duty(nopeus);
ECCPAS0 = 1;
ECCPASE = 0;
delay_ms(10);

while((!ECCPASE) && (nopeus < kiihdytys_nopeus))
{
restart_wdt();
nopeus = nopeus+20;
set_pwm1_duty(nopeus);
delay_ms(10);
if(!input(PIN_C2)) suunta = 20;
if(suunta == 20) if(input(PIN_C2)) suunta = 30;
}
if(!ECCPASE) set_pwm1_duty(NOPEUS_OK);
kahva_old = kahva;
return;
}
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Tue Jan 24, 2012 7:57 am     Reply with quote

Might it be you have ECCPAS0 once with a zero and the other with a capital letter O.
jjude



Joined: 12 Nov 2007
Posts: 37

View user's profile Send private message

PostPosted: Tue Jan 24, 2012 8:29 am     Reply with quote

Douglas Kennedy wrote:
Might it be you have ECCPAS0 once with a zero and the other with a capital letter O.

No. All ECCPAS0 is zero.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Jan 24, 2012 11:01 am     Reply with quote

Have you actually 'cut and pasted' the name between the locations?. This has all the symptoms, of the actual value typed, accidentally having an invisible character in it. Used to be a standard 'trick' for testing how programmers think, where you include a character that doesn't display on the selected font, in the name, and see how long it takes people to work out why the variable isn't recognised as it should be.

Best Wishes
jjude



Joined: 12 Nov 2007
Posts: 37

View user's profile Send private message

PostPosted: Tue Jan 24, 2012 11:32 pm     Reply with quote

Ttelmah wrote:
Have you actually 'cut and pasted' the name between the locations?. This has all the symptoms, of the actual value typed, accidentally having an invisible character in it. Used to be a standard 'trick' for testing how programmers think, where you include a character that doesn't display on the selected font, in the name, and see how long it takes people to work out why the variable isn't recognised as it should be.

Best Wishes

Yes, i copy/paste, no invisible characters!
Aliohjelmat.h files is 5 subroutine, all need paste
#bit ECCPAS0 = 0x17.4 - rows.
I don't understand.
Sorry my bad english...
jjude



Joined: 12 Nov 2007
Posts: 37

View user's profile Send private message

PostPosted: Wed Jan 25, 2012 6:19 am     Reply with quote

I moved "#bit-rows" subroutine files and now compiles OK.
Code:

#bit ECCPAS0 = 0x17.4 // PWM auto shotdown contro
#bit ECCPASE = 0x17.7 // PWM start/stop control
void eteen_kiihdytys()
{
   restart_wdt(); 
   nopeus = NOPEUS_START;
   kiihdytys_nopeus = NOPEUS_OK - 20;
   ECCPAS0 = 1; // Autoshutdown enabled
   ECCPASE = 0; // PWM-start
   set_pwm1_duty(nopeus);
   delay_ms(10);
   while((!ECCPASE) && (nopeus < kiihdytys_nopeus))
   {
      restart_wdt(); 
      nopeus = nopeus+20;
      set_pwm1_duty(nopeus);
      delay_ms(10);
      if(!input(PIN_C2)) suunta = 20;
      if(suunta == 20) if(input(PIN_C2)) suunta = 30;
   }
   if(!ECCPASE) set_pwm1_duty(NOPEUS_OK);
   kahva_old = kahva;
   return;
}
//
.
.
Next subroutines
.
.
Next subroutines
.
.
Next subroutines
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Wed Jan 25, 2012 10:54 am     Reply with quote

One little thought leaps into my mind at this point.
Are you compiling directly with the CCS compiler/IDE, or are you perhaps using MPLAB as the development environment?.
This fault is 'classic' for the latter, and having made the mistake of putting the names of the 'include' files, into the project definitions. If this is done, MPLAB will attempt to compile these separately, so stuff defined in the main file won't be defined.
Only C files that should themselves be compiled should be in the project definitions when running this way.

Best Wishes
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