EasyManua.ls Logo

Cmsemicon SC8F577 Series - Page 46

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
46 / 181
www.mcu.com.cn
6.2 PORTA
6.2.1 PORTA Data and Direction Control
PORTA is 8 Bit bi-directional port. Its corresponding data direction register is TRISA. Setting 1 bit of
TRISA to be 1 can configure the corresponding pin to be input. Setting 1 bit of TRISA to be 0 can configure
the corresponding pin to be output.
Reading PORTA register reads the pin status. Writing PORTA write to port latch. All write operation is
read-change-write. Hence, write 1 port means read the pin electrical level of the port, change the value and
write the value into port latch. Even when PORTA pin is used as analog input, TRISA register still control the
direction of PORTA pin. When use PORTA pin as analog input, user must make sure the bits in TRISA register
are kept as 1.I/O pin is always read 0 when configured as analog input.
Registers related to PORTA ports are PORTATRISAWPUAIOCAANSEL0 and etc.
PORTA data register PORTA (05H)
05H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
PORTA
RA7
RA6
RA5
RA4
RA3
RA2
RA1
RA0
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
PORTA<7:0>:
PORTAI/O pin bit
1=
Port pin level>VIH
0=
Port pin level<VIL.
PORTA direction register TRISA (85H)
85H
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
TRISA
TRISA7
TRISA6
TRISA5
TRISA4
TRISA3
TRISA2
TRISA1
TRISA0
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
TRISA<7:0>:
PORTA tristate control bit
1=
PORTA pin set to be input(tristate)
0=
PORTA pin set to be output.
exampleprocedure for PORTA
LDIA
B11110000
;set PORTA<3:0> as output port, PORTA<7:4>as input port
LD
TRISA, A
LDIA
03H
;PORTA<1:0>output high level, PORTA<3:2>output low level
LD
PORTA, A
;since PORTA<7:4>are input ports, 0 or 1 does not matter

Related product manuals