A trivial query on GPIO

Status
Not open for further replies.

phaedrus

Member
Ok its not so trivial .

I am using an 16F819.I have configured some pins as Input and others as Output.
I have a situation where I wish to switch OFF all the output pins ( i.e. make the pins go LOW).
I am writing thus
PORTA=0;
PORTB=0;
I am not masking out the Input pins.My query is,if i do the above , does it affect the Input pins' capability to read the status of an input ?
 
I am not masking out the Input pins.My query is,if i do the above , does it affect the Input pins' capability to read the status of an input ?

As you are not writing to the TRIS register, it will not affect the ability to read the inputs.
 
Have a look at page 40 of the datasheet for figure 5-1 "BLOCK DIAGRAM OF RA0/AN0:RA1/AN1 PINS". This shows how a single port pin works and illustrates the latches used for writing along with the buffer used for input.

When you write to PORTA you actually write to this series of data latches. When you read it comes from the input buffer. The setting of the related TRIS register (along with analogue input settings and other special functions) determines what will actually be electrically connected.

So in short: no, it doesn't matter if you write to the whole of PORTA, even if some pins are inputs.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…