Truncated match.
PICList
Thread
'Help with Ports'
2000\05\01@230845
by
Brian Gracia
Hello,
I am confused. If I want to set PortB to output then I do the following
from my understanding:
movlw 0x00
tris PortB
Now PortB is set to output. Now if I do the following:
clrf PortB
the ports are set to output low. When you set a port to output mode, does
the port automatically output high and I have to tell it I want it to go
low? Please give code examples and explain. I am missing something!!
TIA,
Brian
********************************************
Better Produce through Better Control
********************************************
2000\05\01@232127
by
l.allen
Brian Wrote
> I am confused. If I want to set PortB to output then I do the following
> from my understanding:
>
> movlw 0x00
> tris PortB
>
> Now PortB is set to output. Now if I do the following:
>
> clrf PortB
>
> the ports are set to output low. When you set a port to output mode, does
> the port automatically output high and I have to tell it I want it to go
> low? Please give code examples and explain. I am missing something!!
>
Nop
Its more that you should never trust a PIC (or any micro)
to be all nice and cleanly reset after power up.
A good old clearing of registers guarantees there are not
any stray '1's lurking there.
_____________________________
Lance Allen
Technical Officer
Uni of Auckland
Psych Dept
New Zealand
http://www.psych.auckland.ac.nz
_____________________________
2000\05\01@233000
by
David Duffy
|
<x-flowed>Brian wrote:
>Hello,
>
>I am confused. If I want to set PortB to output then I do the following
>from my understanding:
>
>movlw 0x00
>tris PortB
Yes
>Now PortB is set to output. Now if I do the following:
>
>clrf PortB
>
>the ports are set to output low. When you set a port to output mode, does
>the port automatically output high and I have to tell it I want it to go
>low? Please give code examples and explain. I am missing something!!
When you set a port to output, the bits are as set in it's data register.
At the start of your program, you should set the data registers to what you
want the initial states to be and also set up the direction registers. (tris)
When the PIC resets, the tris registers will be all inputs (11111111) and
the data registers are undefined. Best to set data 1st then do your tris 2nd.
You can set a bit by doing; bsf PortB,x (where x is the bit you want)
The bcf instruction does the same but clears the specified bit.
Regards...
</x-flowed>
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- Today
- New search...