8XC196LX SUPPLEMENT
impedance input, or open-drain output. The port direction and data output registers select the con- figuration for each pin. Complementary output means that the microcontroller drives the signal high or low. High-impedance input means that the microcontroller floats the signal. Open-drain output means that the microcontroller drives the signal low or floats it. For I/O mode, the port data output register determines whether the microcontroller drives the signal high, drives it low, or floats it. For special-function mode, the on-chip peripheral or system function determines whether the microcontroller drives the signal high or low for complementary outputs.
The pins for ports 1, 2, 5, and 6 are weakly pulled low during and after reset. Initializing the pins by writing to the port mode register turns off the weak pull-downs. To ensure that the ports are initialized correctly, follow this suggested initialization sequence:
1.Write to Px_DIR to configure the individual pins. Clearing a bit configures a pin as a complementary output. Setting a bit configures a pin as a high-impedance input or open- drain output.
2.Write to Px_MODE to select either I/O or special-function mode. Writing to Px_MODE (regardless of the value written) turns off the weak pull-downs. Even if the entire port is to be used as I/O (its default configuration after reset), you must write to Px_MODE to ensure that the weak pull-downs are turned off.
3.Write to Px_REG.
For complementary output configurations:
In I/O mode, write the data that is to be driven by the pins to the corresponding Px_REG bits. In special-function mode, the value is immaterial because the on-chip peripheral or system function controls the pin. However, you must still write to Px_REG to initialize the pin.
For high-impedance input or open-drain output configurations:
In I/O mode, write to Px_REG to either float the pin, making it available as a high impedance input, or pull it low. Setting the corresponding Px_REG bit floats the pin; clearing the corresponding Px_REG bit pulls the pin low. In special-function mode, if the on-chip peripheral uses the pin as an input signal, you must set the corresponding Px_REG bit so that the pin can be driven externally. If the on-chip peripheral uses the pin as an output signal, the value of the corresponding Px_REG bit is immaterial because the on- chip peripheral or system function controls the pin. However, you must still write to Px_REG to initialize the pin.
5.2.2Special Bidirectional Port Considerations
This section outlines special consideration for using the pins of ports 1, 2, 5, and 6.
1.After reset, your software must configure the device to match the external system. This accomplished by writing appropriate configuration data into Px_MODE. Writing to Px_MODE not only configures the pins but also turns off the transistor that weakly holds the pins low. For this reason, even if your port is to be used as it is configured at reset, you should still write data into Px_MODE.
2.P2.6/TXJ1850 is the enable pin for ONCE mode. Because a high input during reset can cause the device to enter ONCE mode or a reserved test mode, caution must be exercised
5-4