I'm new to using PIC's and I'd normally determine this by experimentation but my PICs, development system & PCWH compiler are all still in the order pipeline.
How exactly does one go about reading back the state of one or more output bits on a port that has a mix of input & output bits? I assume the INPUT() and INPUT_x() functions are NOT used because I believe they would change the electrical I/O direction for the port (or they may not depending on which FIXED/FAST/STANDARD_IO directive is in play; I don't know for sure).
Also, what is the preferred way of setting the states of multiple output bits on a port that is a mix of inputs and output bits? Can a whole byte be written to the port without it affecting the input bits if the port is setup for FIXED_IO?
Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 11312
Trampas Stern Guest
Re: How to read back state of output bits?
Posted: Wed Feb 05, 2003 3:04 pm
You need to throw away all the pre defined compiler functions. They will get you into trouble really quick! Instead read the datasheet and do it at a low level:
//set the port up the way you want it
TRIS_A=0xFE; //All input except bit 0
char data;
data=PORT_A; //read the data, will read the output bit
PORT_A=0x01 //set bit zero to one
The problem with the pre defined compiler functions is that you will have to read the listing file to figure out what they do. By the time you have figured out the assembly code of each function you could have wrote it yourself!
Trampas
:=I'm new to using PIC's and I'd normally determine this by experimentation but my PICs, development system & PCWH compiler are all still in the order pipeline.
:=
:=How exactly does one go about reading back the state of one or more output bits on a port that has a mix of input & output bits? I assume the INPUT() and INPUT_x() functions are NOT used because I believe they would change the electrical I/O direction for the port (or they may not depending on which FIXED/FAST/STANDARD_IO directive is in play; I don't know for sure).
:=
:=Also, what is the preferred way of setting the states of multiple output bits on a port that is a mix of inputs and output bits? Can a whole byte be written to the port without it affecting the input bits if the port is setup for FIXED_IO?
:=
:=Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 11316
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