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

How do I pass a pin definition through a function.

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



Joined: 13 Oct 2003
Posts: 32

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

How do I pass a pin definition through a function.
PostPosted: Tue May 13, 2008 9:08 am     Reply with quote

I have several pins
#define Reader1 pin_b0
#define Reader2 pin_b1
#define Reader3 pin_b2

Currently each pin has its own function. I would like to make it so that I have one function that can use all 3 pins...

Something like
ReadTemp(Reader1);
ReadTemp(Reader2);
ReadTemp(Reader3);

The only thing is I don't know how to declare the variable in the function void ReadTemp(xxxxx); I don't know what to put in the xxxx to allow the pin number to be used...

Any help is greatly appreciated..
Ttelmah
Guest







PostPosted: Tue May 13, 2008 10:11 am     Reply with quote

int16.

So something like:
Code:

int16 ReadTemp(int16 pin) {
   output_high(pin);
   return(what_you_want);
}


This is only supported in the latter compilers (older version 3 compilers only supported constants for the pin definitions). Routines to allow a variable to access a pin, for the older compilers, have been posted here on several occasions.

Best Wishes
delene



Joined: 13 Oct 2003
Posts: 32

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

PostPosted: Tue May 13, 2008 10:17 am     Reply with quote

THANK you thank you thank you...
I will give a try in the morning, and hopefully it will work...
Thanks for the help
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Wed May 14, 2008 1:49 am     Reply with quote

P.S. That works only with v4. However, I guess most users of v3 knows about this limitation.
_________________
Read the label, before opening a can of worms.
Ttelmah
Guest







PostPosted: Wed May 14, 2008 2:00 am     Reply with quote

I do mention this limitation. PCM programmer, and myself (amongst others), have posted code to access the pins with a variable, for the V3 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