View previous topic :: View next topic |
Author |
Message |
Geoffry Guest
|
port input without changing port direction |
Posted: Sun Aug 26, 2007 1:11 pm |
|
|
Is it possible to input an entire 8 bit port without changing the direction using the 16F series PICs? I have some pins on the port configured to output, and some to input.
i.e. same idea as input_state(PIN) , but input an entire port instead |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 26, 2007 1:27 pm |
|
|
There are two ways. You can temporarily enable "fast i/o" mode for
the input_b() operation, or you can declare the Port B address and read
the port directly. Both these methods produce the same ASM code in
the .LST file. They don't touch the TRISB register.
Code: |
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#byte PortB = 6
//=================================
main()
{
int8 c;
#use fast_io(B)
c = input_b();
#use standard_io(B)
c = PortB;
while(1);
}
|
|
|
|
Geoffry Guest
|
Thanks |
Posted: Sun Aug 26, 2007 9:32 pm |
|
|
Thanks so much! Exactly what I needed. |
|
|
|