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 support@ccsinfo.com

Accessing Digital I/O from within a for loop

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







Accessing Digital I/O from within a for loop
PostPosted: Fri Jun 02, 2006 6:22 am     Reply with quote

I am trying to read 5 digital I/O pins in a for loop.

Each time through the loop I want to read 1 dig i/o pin.

i.e.

pass 1 read PB0
pass 2 read PC3
pass 3 read PA3

etc.

I am using CCS C compiler and they have an input() function that uses a constant for each I/O pin #

In the header file they have each i/o pin defined.

I tried using a data table

BYTE CONST INPUT_PINS[6]= {PIN_B0,PIN_C2,PIN_B1,PIN_C4,PIN_C3};

in the loop I used the following

if (!input(INPUT_PINS[i]))

but the compiler complains that "Expression must evaluate to a constant"

What is the proper way to do this?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Jun 02, 2006 7:26 am     Reply with quote

The same question was asked yesterday.

For a replacement function accepting variable pin numbers see:
PIC16: http://www.ccsinfo.com/forum/viewtopic.php?t=25280
PIC18: http://www.ccsinfo.com/forum/viewtopic.php?t=25591
Christophe



Joined: 10 May 2005
Posts: 323
Location: Belgium

View user's profile Send private message

PostPosted: Fri Jun 02, 2006 7:30 am     Reply with quote

Now that was exactly my problem yesterday. You will find solution + implementation here:

http://www.ccsinfo.com/forum/viewtopic.php?t=27192

rgds
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