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

Undefined Identifier Error

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



Joined: 07 May 2005
Posts: 28
Location: Campbell, CA

View user's profile Send private message

Undefined Identifier Error
PostPosted: Sat May 14, 2005 11:44 am     Reply with quote

I have included a code fragment below. In the line flagged, I get the error "Undefined Identifier"

What I am trying to do is to read the state of an input pin, and
set a flag equal to that state.

Can someone tell me what I'm doing wrong?

//Below is the last part of an ISR

set_RTCC(0x67);
Flg1 = Input_PIN_A0; // Error occurs here

}

// Beginning of main program

void main()
{
int8 a;
int1 Flg1;
int1 Flg2;
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat May 14, 2005 11:51 am     Reply with quote

Try input(PIN_A0)

Also, see the manual page 122
Charles Linquist



Joined: 07 May 2005
Posts: 28
Location: Campbell, CA

View user's profile Send private message

PostPosted: Sat May 14, 2005 12:25 pm     Reply with quote

I tried the construct

FLG1 = input(Pin_A0);

as suggested, but it still tells me that

FLG1 is an "Undefined Identifier"
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat May 14, 2005 12:38 pm     Reply with quote

Either you have the CASE preprocessor line included (it is normally not case sensitive) or the declaration is out of scope. What you posted is not enough to tell where you are using the input() command. The variable either has to be defined in the routine where you are using it or, if it is global, the declaration line must be physically BEFORE any instance of it being used in the code.

BTW, What version PIC and compiler are you using?


Last edited by dyeatman on Sat May 14, 2005 12:43 pm; edited 1 time in total
Gerrit



Joined: 15 Sep 2003
Posts: 58

View user's profile Send private message

PostPosted: Sat May 14, 2005 12:40 pm     Reply with quote

I think you have te declare the variable global.
Not in main.


Gerrit
Charles Linquist



Joined: 07 May 2005
Posts: 28
Location: Campbell, CA

View user's profile Send private message

PostPosted: Sat May 14, 2005 3:32 pm     Reply with quote

That was my trouble. I needed to define the variable before I used it.
Thanks!

I'm trying to measure the RPM of a fan, and I need to know how many times a bit (tachometer) toggles in X milliseconds.

In PicBasic, I would use the routine

If PORTA.0 <> OldPortA THEN
Counter = Counter+1
OldPortA = PortA.0
ENDIF


In my C program, I have a 1msec timer interrupt running and I'm having trouble figuring out how to do the same thing. Is there some elegant way?

I'm not trying to be a pest, I'm just a newbie that is having a hard time.


I'm using compiler version 3.224
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat May 14, 2005 4:48 pm     Reply with quote

Charles,
Usng the latest version, great!

Need to know a little more about what you are doing.

What PIC are you using and where are you connecting your fan tach input?
Is your timer on Timer0? Timer1?

If can you post the code you have so far it likely will answer most of the questions and we can help you clean it up and get it running the way you want.

P.S. PLease use the Code button when posting your code to retain the formatting.
Charles Linquist



Joined: 07 May 2005
Posts: 28
Location: Campbell, CA

View user's profile Send private message

PostPosted: Sat May 14, 2005 6:26 pm     Reply with quote

I'm using an 18F452, although I will port it over to an 18F8722
I'm running the '452 at 20Mhz, My interrupt is tied to TMR0

Code:



#include <18F458.h>
#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP

#use delay(clock=20000000) // 20MHz clock
#use fast_io(b)

int1 Flg1;
  int1 Flg2;
  int1 Flg3;
  int1 Flg4;
  int1 Flg5;
  int1 Flg6;
  int1 Flg7;
  int1 Flg8;
  int8 ToggleCounter1;
  int8 ToggleCounter2;
  int8 ToggleCounter3;
  int8 ToggleCounter4;
  int8 ToggleCounter5;
  int8 ToggleCounter6;
  int8 ToggleCounter7;
  int8 ToggleCounter8;



#int_rtcc
RTCC_isr()
{
  output_toggle(PIN_B0);
  set_RTCC(0x67);
 
  IF (Input(Pin_A0) != Flg1);
    {++ToggleCounter1
  Flg1 = Input(Pin_A0);
  }
 

}


void main()
{
  int8 a;

  port_b_pullups(TRUE);
  setup_adc_ports(NO_ANALOGS);
  setup_adc(ADC_OFF);
  setup_psp(PSP_DISABLED);
  setup_spi(FALSE);
  setup_wdt(WDT_OFF);
  setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32|RTCC_8_bit);
  setup_timer_1(T1_DISABLED);
  setup_timer_2(T2_DISABLED,0,1);
  setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
  enable_interrupts(INT_RTCC);
  enable_interrupts(GLOBAL);
  set_tris_b(0x00);
  set_tris_a(0xFF);


  a = 0;

  while (a == 0)    // Note the '==' and no ';' here !!!
  {
    output_toggle(PIN_B1);
    delay_ms(500);   // Need to see if it is running without a scope
  }
}
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