Maker Pro
Maker Pro

TrisA Output Mask on Pic - doesn't block?

C

ChronoFish

Jan 1, 1970
0
Hi there,

I don't think I understand the purpose of the TRIS registers. My understanding was that it a mask for output and input.

My target is the 16f84a.

So if I set the trisA to 0x3E (00111110) I would expect only pin 1 to be an output (there is no pin 7 or 8 on portA).

Then if I have a variable that gets incremented and loaded into porta I would expect that pin 1 would flash.

It does.

But what I don't expect is that pins 2-5 flash as well. Yes I know that I'm sending 8 bits to portA, but I thought the purpose of
trisA was to mask the I/O.

Is this another case where I have to "tie down" the inputs with a resistor?

Thanks!
CF

(it may take awhile, but I'll get it eventually.... I hope)
 
G

Guest

Jan 1, 1970
0
I don't think I understand the purpose of the TRIS registers. My understanding was that it a mask for output and input.
My target is the 16f84a.

So if I set the trisA to 0x3E (00111110) I would expect only pin 1 to be an output (there is no pin 7 or 8 on portA).

Then if I have a variable that gets incremented and loaded into porta I would expect that pin 1 would flash.

It does.

But what I don't expect is that pins 2-5 flash as well. Yes I know that I'm sending 8 bits to portA, but I thought the purpose of
trisA was to mask the I/O.

Is this another case where I have to "tie down" the inputs with a resistor?

Thanks!
CF

(it may take awhile, but I'll get it eventually.... I hope)

Try something like this;

BANK0 macro
bcf STATUS,RP1
bcf STATUS,RP0
endm

BANK1 macro
bcf STATUS,RP1
bsf STATUS,RP0
endm

BANK1
MOVLW 0x3e ; PORTA.0 = output. Rest (1-5) are inputs
MOVWF TRISA
BANK0

Tris registers are in bank1, and port registers are in bank 0 - so you need
make sure and switch to the appropriate register bank when writing to various
registers. The BANK macros just make it easier.

Just make sure you're in bank0 when you write to a port - bank 1 when you
write to a tris (direction control) register, and you should be good to go.


Regards,

-Bruce
[email protected]
http://www.rentron.com
 
Top