View previous topic :: View next topic |
Author |
Message |
delene
Joined: 13 Oct 2003 Posts: 32
|
How do I pass a pin definition through a function. |
Posted: Tue May 13, 2008 9:08 am |
|
|
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
|
|
Posted: Tue May 13, 2008 10:11 am |
|
|
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
|
|
Posted: Tue May 13, 2008 10:17 am |
|
|
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
|
|
Posted: Wed May 14, 2008 1:49 am |
|
|
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
|
|
Posted: Wed May 14, 2008 2:00 am |
|
|
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 |
|
|
|