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

function passing pin no ?

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



Joined: 06 Mar 2007
Posts: 92
Location: Pune,India

View user's profile Send private message AIM Address Yahoo Messenger

function passing pin no ?
PostPosted: Fri Jun 22, 2007 3:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 22, 2007 8:58 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 22, 2007 9:20 am     Reply with quote

One of these should lead you in the right direction:

For 16F:
http://www.ccsinfo.com/forum/viewtopic.php?t=25280&start=4

For 18F:
http://www.ccsinfo.com/forum/viewtopic.php?t=27723&start=3

Thank PCM programmer
_________________
The search for better is endless. Instead simply find very good and get the job done.
inservi



Joined: 13 May 2007
Posts: 128

View user's profile Send private message

PostPosted: Fri Jun 22, 2007 10:27 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 22, 2007 12:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jun 22, 2007 1:02 pm     Reply with quote

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).
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