View previous topic :: View next topic |
Author |
Message |
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
function passing pin no ? |
Posted: Fri Jun 22, 2007 3:39 am |
|
|
Dear Sir,
here i am using 12f629, MPLAB 7.5 Ver. & CCS PCM C Compiler, Version 3.249, 34534.
can i use a function like this
Code: | void SCR_ON(int8);
void main()
{
SCR_ON(PIN_A2); // calling function
SCR_ON(PIN_A4);
}
void SCR_ON(int8 trigger)
{
OUTPUT_HIGH(trigger);
DELAY_US(60);
OUTPUT_LOW(trigger);
} |
_________________ Thank You,
With Best Regards,
Deepak. |
|
|
inservi
Joined: 13 May 2007 Posts: 128
|
|
Posted: Fri Jun 22, 2007 8:58 am |
|
|
Hello,
why not use output_bit (pin, value) ?
like Code: | int16 i=PIN_B0;
output_bit(i,1);
|
Code: | void SCR_ON(int16);
void main()
{
SCR_ON(PIN_A2); // calling function
SCR_ON(PIN_A4);
}
void SCR_ON(int16 trigger)
{
OUTPUT_BIT(trigger,1);
DELAY_US(60);
OUTPUT_BIT(trigger,0);
}
|
I think that int16 or int8 is depending on witch PIC used ?
dro. _________________ in médio virtus
Last edited by inservi on Fri Jun 22, 2007 10:11 am; edited 1 time in total |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
|
inservi
Joined: 13 May 2007 Posts: 128
|
|
Posted: Fri Jun 22, 2007 10:27 am |
|
|
Thank-you SherpaDoug,
Why make so complicated when output_bit (pin, value) work well ?
(for 12F629, int8 must working because addresses of A0 to A5 are 40 to 45).
dro. _________________ in médio virtus |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Fri Jun 22, 2007 12:03 pm |
|
|
I get the error "Expression must evaluate to a constant" with output_bit (pin, value) where pin is an int. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 22, 2007 1:02 pm |
|
|
It depends on the compiler version. CCS added the ability to use a
variable for the pin parameter in version 4 of the compiler.
I don't know the exact version in which it became available, but I tested
version 4.042 and it does compile OK in that version.
Those two routines that Sherpa Doug linked to are for people who
have version 3.xxx and earlier (that's a lot of people). |
|
|
|