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

Output_high() function

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







Output_high() function
PostPosted: Sun Dec 22, 2002 2:22 pm     Reply with quote

Hi everyone,

I have a variable which contain the address of a port, but I want to use this variable for the Output_high() function. The Output_High() function, as you know, requires a constant in its argument. How do I "convert" the content of a variable to a constant so I can use in the Output_High() function.

test = BIT_A3;
Output_High(test); //?

Thank you in advance


___________________________
This message was ported from CCS's old forum
Original Post ID: 10202
Dale Herman
Guest







Re: Output_high() function
PostPosted: Sun Dec 22, 2002 4:47 pm     Reply with quote

cant
<a href="http://www.ccsinfo.com/faq/?26" TARGET="_blank">http://www.ccsinfo.com/faq/?26</a>
___________________________
This message was ported from CCS's old forum
Original Post ID: 10203
Tomi
Guest







Re: Output_high() function
PostPosted: Mon Dec 23, 2002 2:34 am     Reply with quote

If you use FIXED_IO or any other way to be sure that the port pin is in output state then you can use the following:

void My_Output_High(char bitaddress)
{
char byteaddr,bitaddr;

byteaddr = bitaddress >> 3;
bitaddr = bitaddress & 0x07;
bit_set(*byteaddr,bitaddr);
}

If you use 16F87X then it is possible to use:

void My_Output_High(char bitaddress)
{
char byteaddr,bitaddr;

byteaddr = bitaddress >> 3;
bitaddr = bitaddress & 0x07;
bit_clear(*(byteaddr | 0x80),bitaddr); // set pin to output
bit_set(*byteaddr,bitaddr);
}

And of course you can use the same way for 18Fxx2 to compute the right TRIS register address.


:=Hi everyone,
:=
:=I have a variable which contain the address of a port, but I want to use this variable for the Output_high() function. The Output_High() function, as you know, requires a constant in its argument. How do I "convert" the content of a variable to a constant so I can use in the Output_High() function.
:=
:=test = BIT_A3;
:=Output_High(test); //?
:=
:=Thank you in advance
:=
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 10212
Bruce R. Knox
Guest







Re: Output_high() function
PostPosted: Mon Dec 23, 2002 7:37 am     Reply with quote

:=Hi everyone,
:=
:=I have a variable which contain the address of a port, but I want to use this variable for the Output_high() function. The Output_High() function, as you know, requires a constant in its argument. How do I "convert" the content of a variable to a constant so I can use in the Output_High() function.
:=
:=test = BIT_A3;
:=Output_High(test); //?
:=
:=Thank you in advance
:=
:=

Assuming you mean that your variable contains the address of a BIT on a port, why not use bit_set(addr,bit)?

For example:

#byte PORTA = 5
int test;

test = 3; // Bit 3 position
bit_set(PORTA,test); // as in the CCS manual!

Of course, you'll have to have set up the TRIS register(s) on your own to use this method.

Bruce
___________________________
This message was ported from CCS's old forum
Original Post ID: 10214
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