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 to change the direction of a I/O ?

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



Joined: 12 Sep 2003
Posts: 32
Location: France (Paris)

View user's profile Send private message

How to change the direction of a I/O ?
PostPosted: Wed Mar 15, 2006 7:59 am     Reply with quote

Hi all,

In my software, I am using the #USE FAST_IO directive.
Is there a function like "SET_TRIS_X" but for only one bit (and not a Byte) ?

Thank you
Franck
Ttelmah
Guest







PostPosted: Wed Mar 15, 2006 8:25 am     Reply with quote

Not really. The tris register is 'byte wide'. However there are any number of ways of doing this.
1) Have a variable, containing the actual value you want to put into tris. Do a bit set/reset function, and then send the whole variable.
2) Declare the the register yourself using the #byte statement, and then use the #bit statements with this. So:
Code:

#define INPUT (1)
#define OUTPUT (0)
#byte TRISA=0xF80
#byte TRISB=0xF81
#byte TRISB=0xF82
#byte TRISC=0xF83
//etc., for as many TRIS registers as you have - change the addresses
//for PIC16/12 chips

Then either declare a structure for the bits, and map it to these locations (#locate), use the bit I/O functions, or just use bit statements, like:
Code:

#bit TRISA0=TRISA.0
#bit TRISA1=TRISA.1
//etc..

Then you can just use 'TRISA0=OUTPUT', which makes everything nice and clear!.
Alternatively, with the bit I/O functions, and the 'byte' declarations alone, you can use:

bit_clear(TRISA,0);

or the corresponding 'bit_set' function.

Best Wishes
franckcl



Joined: 12 Sep 2003
Posts: 32
Location: France (Paris)

View user's profile Send private message

PostPosted: Wed Mar 15, 2006 8:31 am     Reply with quote

Thank you for your complet respons.
I try this now.

Thank you
Franck
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