View previous topic :: View next topic |
Author |
Message |
FFT
Joined: 07 Jul 2010 Posts: 92
|
FAST_IO / STANDARD_IO |
Posted: Tue Jul 13, 2010 3:29 pm |
|
|
Hello,
Before I've been using #use fast_io(D) because all pins were fixed. But now I connected to the PIN_D3 a one-wire sensor and of course this pin must be both input and output. But the other pins are fixed. 1 input and the others are outputs. If I use again #use fast_io(D), the sensor does not work, because the pin is fixed input or output.
Now, How can I force the CCS to generate optimal assembly code for the fixed pins and STANDARD_IO code for the bidirectional (one wire) pin? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 13, 2010 5:26 pm |
|
|
You can put #use standard_io and #use fast_io anywhere in your
program, as much as you want, to control the behavior of the
compiler for code that occurs after that line. Example:
Code: |
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#define ONE_WIRE_PIN PIN_D0
#use standard_io(D) // Use standard i/o for the 1-wire driver
#include "1wire.c"
#use fast_io(D) // Use fast i/o for the rest of the program
//==========================================
void main()
{
set_tris_d(0x01); // Pin D0 stays as input
output_high(PIN_D1); // This will use Fast i/o
onewire_reset(); // This will use Standard i/o
output_low(PIN_D1); // This will use Fast i/o
while(1);
} |
|
|
|
FFT
Joined: 07 Jul 2010 Posts: 92
|
|
Posted: Wed Jul 14, 2010 6:04 am |
|
|
Wow, I didn't know that, thank you so much |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Wed Jul 14, 2010 1:19 pm |
|
|
You can also set up control over the IO Direction control registers (TRIS) and change in Input/Output config as you need.
When I need mostly fast_io, I usually do that.
Either way works.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|