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

define input

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



Joined: 26 Feb 2013
Posts: 30
Location: Algeria

View user's profile Send private message

define input
PostPosted: Thu Mar 28, 2013 6:22 am     Reply with quote

hi guys, I have a problem when I defined a 'Pin' of the microcontroller as input.

Example:
Code:
#include <16F877A.h>
#device adc=16

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=20000000)

#define UP input(PIN_D2);
void main()
{

   while(TRUE)
   {
     if (!UP)
     {output_low(PIN_B4); }
}

Error when i compile:

Expecting a close paren
A numeric expression must appear here

I use CCS compiler v4.130
temtronic



Joined: 01 Jul 2010
Posts: 9255
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 28, 2013 6:32 am     Reply with quote

I see
3 {
and
2 }

so the error message seems correct ..

hth
jay
vortexe90



Joined: 26 Feb 2013
Posts: 30
Location: Algeria

View user's profile Send private message

PostPosted: Thu Mar 28, 2013 7:04 am     Reply with quote

I corrected the accolade but I still get the error


Code:
#include <16F877A.h>
#device adc=16

#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=20000000)

#define UP input(PIN_D2);
void main()
{

while(TRUE)
{
if (!UP) //-------------------> I corrected this accolade but I still get the error here
{output_low(PIN_B4);}
}
}
jeremiah



Joined: 20 Jul 2010
Posts: 1358

View user's profile Send private message

PostPosted: Thu Mar 28, 2013 7:31 am     Reply with quote

Take a look at your #define. You did it incorrectly. It replaces UP with everything after it.
milan.rajik2013



Joined: 26 Mar 2013
Posts: 3
Location: Moscow

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 28, 2013 7:53 am     Reply with quote

Use #define UP PIN_D2;

If PIN_D2 is a switch then you have to use debounce delay otherwise your code will not work.

Code:

if(UP == 1) {
       delay_ms(50);
       if(UP == 1) {
       
             PIN_D4 = ~PIN_D4;

       }
}


_________________
Regards
Milan


Last edited by milan.rajik2013 on Thu Mar 28, 2013 7:58 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19569

View user's profile Send private message

PostPosted: Thu Mar 28, 2013 7:57 am     Reply with quote

As a 'what to look for'. Jeremiah is giving the right answer.

'Defines' in C are text replacement macros. Exactly what is typed in the second part replaces what is typed in the first.

Take what is on your define line, as the replacement part, and type it in yourself where you use this. Does it look right?.
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