
Rev. 1.1
R8C25 QuickDesign Guide.doc Page 5 of 10 12/23/2007
• Port 0 direction register is protected from accidental modification.
Before modifying this register Bit 2 in the Protect Register (PRCR) must
be Set. The protection bit is automatically Reset by the next internal
write operation of the MCU; therefore the setting of the Protect bit and
the modification of the direction register should be consecutive
instructions with interrupts disabled during this time (see the Protection
Section for more information)
• When setting a pin as an output it is recommended that the desired output
value of the port be written to the data latch first, then the direction register is
set to an output. Though not important in all systems, this prevents an
unintended output glitch on the port being setup.
• P4_2 can be used as an input if AD is not used. If AD is used this pin must
have a Vref voltage applied to it (see ADC section for more information)
5.2. Internal Pull-Up Resistors
• Most GPIO can have internal pull-up resistors enabled when they are used as
an input. The pullup resistors are typically applied as groups of pins, see the
HW manual for the grouping.
• If any pin is set to an output by setting the associated DDR to 1 the internal
pullup for that pin will be disabled.
5.3. Unassigned pins–
See section 7.5 of the HW manual for specific recommendations. For most
GPIO the designer has two options with regard to handling unused pins. If a
pin is just left floating it can consume extra power and is leaves the system
more susceptible to noise problems.
The first option is to set the pin to an input (the default state after Reset) and
connect the pin to Vcc or Vss using a resistor. There is no difference from an
MCU standpoint to one connection or another, however, there may be an
advantage from a system noise perspective. Vss is probably the most typical
choice. Connecting directly to Vcc or Vss is not recommended since a
direction register getting accidentally set to an output could create a shorted
output.
The second method sets the pin to an output. It does not really matter whether
the pin level is set high or low, however, selecting the pin as an output and
low connects the pin internally to the ground plane. This may help with
overall system noise concerns. One disadvantage the method of setting the
port pin to an output is that the configuration of the port must be done via
software control. While the MCU is held in Reset and until the direction
register is set for output the pin will be a gloating input. However, if the extra
current can be tolerated during this time this does eliminate the pull-up
resistors required in previous method.
A variation on leaving the pins as inputs uses the internal pull-up resistors of
the MCU. This has the same limitation as setting the pins to outputs (requires
the program to set the port up) but it does limit the effect of accidental pin
shorts to ground, adjacent pins or Vcc since the device will not be driving the
pin.
Comentarios a estos manuales