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

Help For reading Port Data

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



Joined: 05 Jun 2013
Posts: 10
Location: Mumbai

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

Help For reading Port Data
PostPosted: Thu Jun 06, 2013 1:06 am     Reply with quote

I am using PIC 16F873A controller 8 keys attached to controller. On PORT_A (6 keys) from Pin A0-A5, and ON Port B (2 keys) Pin B4, & B5. I am writing Port_A make with pullup make Port_A High and read PORT_A data if Port_A data changes means changes in key status they next process of debounce carried out.
I had write code as following as shown in example but shows error as
: expecting LVALUE such as variable name or * expression

Code:

unsigned int8 key2_data(void);
unsigned int8 data1(void);
unsigned int8 data2(void);
unsigned int8 key_data(void);

void chk_status(void)
{
   data1=input_B();
   data2=input_A();
   key2_data = ( data1 & 0x30);
   key2_data = key2_data <<2;
   key_data  = (( data2 & 0x3F)|( key2_data & 0xa0));
}


i had also change input_B as PORT_B,please guide how to read port data.
_________________
I m Working as PIC Programmer Fresher
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Jun 06, 2013 7:11 am     Reply with quote

Nothing wrong with the input. Problem is the data definitions....
You are defining key2_data, as a _function_ returning an int8, not as a variable.
Same applies to all the other variables....
With some further tidying (for instance, you have already and'ed the incoming port value with 0x30, before the rotation, so why and it again with 0xA0 - just wasted time.
Also as a comment, use local variables, and return the value from the function.
Code:

int8 chk_status(void)
{
   int8 temp;
   temp=(input_B()<<2) & 0xA0);
   temp=(input_A() & 0x3F) | temp;
   return temp;
}


Note the variable declaration, and how the function returns the result.

Do some basic reading on how to declare variables in C.

Best Wishes
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Jun 06, 2013 7:24 am     Reply with quote

you are treating function templates as if they are VARS

read your basic C manual

this is wrong syntax you attempt to compile.

not a CCS problrm

ohh whoops - MR. T was setting this right as i was typing Slowly Very Happy Very Happy Very Happy
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Jun 06, 2013 8:34 am     Reply with quote

Stereo posting is very common. Usually I'm the one typing slower... Smile

Best Wishes
prafulla.prolific



Joined: 05 Jun 2013
Posts: 10
Location: Mumbai

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

PostPosted: Fri Jun 07, 2013 11:56 pm     Reply with quote

Thanks Ttelmah, its my mistake i will try.
Ttelmah wrote:
Nothing wrong with the input. Problem is the data definitions....
You are defining key2_data, as a _function_ returning an int8, not as a variable.
Same applies to all the other variables....
With some further tidying (for instance, you have already and'ed the incoming port value with 0x30, before the rotation, so why and it again with 0xA0 - just wasted time.
Also as a comment, use local variables, and return the value from the function.
Code:

int8 chk_status(void)
{
   int8 temp;
   temp=(input_B()<<2) & 0xA0);
   temp=(input_A() & 0x3F) | temp;
   return temp;
}


Note the variable declaration, and how the function returns the result.

Do some basic reading on how to declare variables in C.

Best Wishes

_________________
I m Working as PIC Programmer Fresher
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