
Freescale
4-6
MC68HC05B6
Rev. 4.1
INPUT/OUTPUT PORTS
4
4.6
Other port considerations
All output ports can emulate ‘open-drain’ outputs. This is achieved by writing a zero to the relevant
output port latch. By toggling the corresponding data direction bit, the port pin will either be an
output zero or tri-state (an input). This is shown diagrammatically in
Figure 4-3.When using a port pin as an ‘open-drain’ output, certain precautions must be taken in the user
software. If a read-modify-write instruction is used on a port where the ‘open-drain’ is assigned
and the pin at this time is programmed as an input, it will read it as a ‘one’. The read-modify-write
instruction will then write this ‘one’ into the output data latch on the next cycle. This would cause
the ‘open-drain’ pin not to output a ‘zero’ when desired.
Note:
‘Open-drain’ outputs should not be pulled above VDD.
Figure 4-3 Port logic levels
DDRn
A
Y
(b)
10
0
Normal operation – tri state
11
1
00
tri state
01
tri state
10
low
‘Open-drain’
11
—
0
high
0
1
high
Y
A
Read buffer output
Data direction register bit DDRn
Px0
VDD
VDD
DDRx, bit 0 = 0
Portx, bit 0 = 0
DDRx, bit 0 = 0
Portx, bit 0 = 0
(c)
(a)
‘Open-drain’ output