|
|
View previous topic :: View next topic |
Author |
Message |
ibg
Joined: 19 Nov 2003 Posts: 22
|
#use fast_io, #use standard_io, set_tris_x() |
Posted: Fri Jan 16, 2004 4:12 am |
|
|
Hi,
I know I've asking things very similar during the last days but I still don't have the ideas clear about the different methods of doing I/O.
First, I know that every pin must be configured as input or output.
If we are using the directive #use fast_io(port), we are forced to set the direction of the pin using the instruction "set_tris_X()". With such instruction we are accesing to the TRIS_X register that is mapped in memory and we are stting 1's(input) or 0's(output) to the diffrent port pins.
1) Am I right about the stated before?
2) What does exactly mean "using a fast method of doing I/O"?
3) If instead of using "use fast_io(port)", we use "#use standard_io(port)", do we have also to use "set_tris_X()" to specify the pin direction? How do we specify in the standard I/O the pin direction?
Thanks once again 4 your help,
Imanol |
|
|
Ttelmah Guest
|
Re: #use fast_io, #use standard_io, set_tris_x() |
Posted: Fri Jan 16, 2004 6:28 am |
|
|
ibg wrote: | Hi,
I know I've asking things very similar during the last days but I still don't have the ideas clear about the different methods of doing I/O.
First, I know that every pin must be configured as input or output.
If we are using the directive #use fast_io(port), we are forced to set the direction of the pin using the instruction "set_tris_X()". With such instruction we are accesing to the TRIS_X register that is mapped in memory and we are stting 1's(input) or 0's(output) to the diffrent port pins.
1) Am I right about the stated before?
2) What does exactly mean "using a fast method of doing I/O"?
3) If instead of using "use fast_io(port)", we use "#use standard_io(port)", do we have also to use "set_tris_X()" to specify the pin direction? How do we specify in the standard I/O the pin direction?
Thanks once again 4 your help,
Imanol |
The 'key', is who controls the pin. With 'fast_io', the compiler does nothing, and _you_ have to control the pin. With 'standard_io', the compiler will automatically change the pin to an input for every input instruction, and change it to an output for every output instruction. The downside of this, is that the extra code to change the direction is added to every input/output instruction. The plus side, is that if you read a pin, you know that the TRIS will be set to allow a read, while if you write a pin, you know an output will be enabled.
The third option is 'fixed_io', which is really the same as fast_io, but you use the fixed_io directive to set the direction control bits, rather than accessing TRIS directly.
Best Wishes |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Jan 16, 2004 6:59 am |
|
|
Different meanings:
#USE xxxx_IO are PRE-PROCESSOR DIRECTIVES and define HOW the compiler will generate code for input and output instructions.
#USE STANDARD_IO (port)
Cause the compiler to generate code to make an I/O pin either input or output every time it is used. Dont need to set the direction registers but generate extra code for every I/O task.It is the default I/O method for all ports.
#USE FAST_IO (port)
Cause the compiler to perform I/O according to previously direction register settings via set_tris_X().
set_tris_x (value)
Is a COMPILER BUILT IN FUNCTION and allow the I/O port direction (TRI-State) registers to be set.
To see these more clearly just make a small test flashing a LED and take a look at the .lst generated.
Try not using #USE directives nor tris_X() function and you will see that all will run anywise.
hope this help,
Humberto |
|
|
|
|
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
|