CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to read back state of output bits?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Warren Massey
Guest







How to read back state of output bits?
PostPosted: Wed Feb 05, 2003 2:49 pm     Reply with quote

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?
PostPosted: Wed Feb 05, 2003 3:04 pm     Reply with quote

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:

#BYTE TRIS_A = 0xF92 //PIC18F8720
#BYTE PORT_A = 0xF80 //PIC18F8720

//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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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