Sure.
TRISA = %00100000
Sets PORTA.5 as an input pin and all others in PORTA as output pin.
There is something here to pay attention for.
Although PORTA is 6-bit (RA0 to RA5), TRIS register uses 8-bit (0 to 7).
In this case, only right bits are considered. Thus, Bit7 and Bit6 in TRISA register are ignored ; whether they are 1 or 0 it won't matter.
TRISE = %00000000
Sets PORTE.0, PORTE.1 and PORTE.2 as output pins.
Also here, PORTE is only 3-bit (RE0 to RE2). So that, all other bits in TRISE register will be ignored.
You can also set an individual bit by,
TRISE.0=0
Sets RE0 as an output pin.
or
TRISE.0=1 sets RE0 as an input pin.
If you set a pin as analog, it must be an input pin.
For Internal Weak Pull-ups, there is a bit in OPTION_REG register.
Bit7.
OPTION_REG.7 is PORTB Pull-up Enable bit
OPTION_REG.7 = 1
PORTB pull-ups are disabled.
OPTION_REG.7 = 0
PORTB pull-ups are enabled by individual port latch values.
Once you set this bit as 0 then you can have weak pull ups on PORTB pins that were set to be input pins beforehand.
-----------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Bookmarks