|
|
View previous topic :: View next topic |
Author |
Message |
franckcl
Joined: 12 Sep 2003 Posts: 32 Location: France (Paris)
|
How to change the direction of a I/O ? |
Posted: Wed Mar 15, 2006 7:59 am |
|
|
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
|
|
Posted: Wed Mar 15, 2006 8:25 am |
|
|
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)
|
|
Posted: Wed Mar 15, 2006 8:31 am |
|
|
Thank you for your complet respons.
I try this now.
Thank you
Franck |
|
|
|
|
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
|