ST72651AR6
49/161
Doc ID 7215 Rev 4
I/O PORTS (Cont’d)
9.2.5 Bit manipulation on Open Drain Outputs
avoid using bit manipulation instructions on the DR
register in open drain output mode, but must al-
ways access it using byte instructions. If bit manip-
ulation is needed, the solution is to use a copy of
the DR register in RAM, change the bits (using
BRES or BCLR instructions for example) and copy
the whole byte into the DR register each time the
value has to be output on a port. This way, no bit
manipulation is performed on the DR register but
each bit of the DR register can be controlled sepa-
rately.
9.3 I/O PORT IMPLEMENTATION
The hardware implementation on each I/O port de-
pends on the settings in the DDR and OR registers
and specific feature of the I/O port such as ADC In-
put or true open drain.
Switching these I/O ports from one state to anoth-
er should be done in a sequence that prevents un-
wanted side effects. Recommended safe transi-
tions are illustrated in
Figure 32 Other transitions
are potentially risky and should be avoided, since
they are likely to present unwanted side-effects
such as spurious interrupt generation.
Figure 32. Interrupt I/O Port State Transitions
The I/O port register configurations are summa-
rized as follows.
Port B (without Option Register)
PB[7:0]
Table 14. Port Configuration (with Option Register)
01
floating/pull-up
interrupt
INPUT
00
floating
(reset state)
INPUT
10
open-drain
OUTPUT
11
push-pull
OUTPUT
XX
= DDR, OR
MODE
DDR
floating input
0
push-pull output
1
Port
Pin name
Input
Output
OR = 0
OR = 1
OR = 0
OR = 1
High-Sink
Port A
PA7:0
floating
with interrupt
open drain
push-pull
No
Port C
PC7:4
floating
with interrupt
push-pull
No
PC3:0
floating
with interrupt
push-pull
Yes
Port D
PD7:0
floating
with interrupt
open drain
push-pull
No
Port E
PE7:6
floating
open drain
push-pull
Yes
PE5
floating
with pull-up, if se-
lected by option
open drain (with
pull-up, if select-
ed by option byte
push-pull
Yes
PE4:3
floating
open drain
push-pull
No
PE2:0
floating
open drain
push-pull
Yes
Port F
PF6:4
floating
True open drain
Yes
PF3:2
floating
push-pull
No
PF1:0
floating
True open drain
Yes
1