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

How to assign input_x to an array ?

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



Joined: 01 Nov 2012
Posts: 1

View user's profile Send private message

How to assign input_x to an array ?
PostPosted: Thu Nov 01, 2012 6:39 am     Reply with quote

Hello everyone,

I want to assign input_x to an array. For example:
I have 8 sensors and I'll use b port on 18f4550 for reading their values 1 or 0.
I declare an array int array[8] in which I don't describe the values,
then I'm going to do array=input_b.
But it doesn't work. It says it needs an LVALUE.
Please, is it possible or not? If it is, where am I doing a mistake?

Thank you.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Nov 01, 2012 9:57 am     Reply with quote

OK. It is not very clear from your description, but I suspect you want to have an array of single bits containing the values from a port?.
If so, answer depends on the age of your compiler.
Code:

union {
   int8 b;
   int1 bits[8];
} port_bits;

    port_bits.b=input_b();

//then port_bits.bits[0] to port_bits.bits[7] are the eight bits from the port


This is only supported on reasonably 'recent' compilers.

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