EasyManua.ls Logo

Cmsemicon SC8F577 Series - Page 50

Default Icon
181 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
V1.8
SC8F577x
50 / 181
www.mcu.com.cn
6.3 PORTB
6.3.1 PORTB Data and Direction
PORTB is an 8Bit wide bi-directional port. The corresponding data direction register is TRISB. Set a bit
in TRISB to 1 (=1) to make the corresponding PORTB pin as the input pin. Clearing a bit in TRISB (=0) will
make the corresponding PORTB pin as the output pin.
Reading the PORTB register reads the pin status and writing to the register will write the port latch. All
write operations are read-modify-write operations. Therefore, writing a port means to read the pin level of the
port first, modify the read value, and then write the modified value into the port data latch. Even when the
PORTB pin is used as an analog input, the TRISB register still controls the direction of the PORTB pin. When
using the PORTB pin as an analog input, the user must ensure that the bits in the TRISB register remain set
as 1. I/O pin is always read 0 when configured as analog input.
Related registers with PORTB port include PORTBTRISBWPUBWPDBIOCBANSEL1 and etc.
PORTB data register PORTB (06H)
06H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PORTB
RB7
RB6
RB5
RB4
RB3
RB2
RB1
RB0
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset value
X
X
X
X
X
X
X
X
Bit7~Bit0
PORTB<7:0>:
PORTB I/O pin bit
1=
Port pin level >VIH
0=
Port pin level<VIL
PORTB direction register TRISB (86H)
86H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
TRISB
TRISB7
TRISB6
TRISB5
TRISB4
TRISB3
TRISB2
TRISB1
TRISB0
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
reset value
1
1
1
1
1
1
1
1
Bit7~Bit0
TRISB<7:0>:
PORTB tristate control bit
1=
PORTB pin configured as input(tristate)
0=
PORTB pin configured as output
Example: PORTB port procedure
CLR
PORTB
;clear data register
LDIA
B’00110000’
;set PORTB<5:4> as input port, others as output port
LD
TRISB, A

Related product manuals