Intel Microcontroller, 80C196NU, 8XC196NP manual Bidirectional Port Pin Configurations

Models: Microcontroller 80C196NU 8XC196NP

1 471
Download 471 pages 22.3 Kb
Page 152
Image 152

I/O PORTS

7.2.2Bidirectional Port Pin Configurations

Each bidirectional port pin can be individually configured to operate either as an I/O pin or as a pin for a special-function signal. In the special-function configuration, the signal is controlled by an on-chip peripheral or an off-chip component. In either configuration, two modes are possible:

complementary output (output only)

high-impedance input or open-drain output (input, output, or bidirectional)

To prevent the CMOS inputs from floating, the bidirectional port pins are weakly pulled high dur- ing and after reset, until your software writes to Px_MODE. The default values of the control reg- isters after reset configure the pins as high-impedance inputs with weak pull-ups. To ensure that the ports are initialized correctly and that the weak pull-ups are turned off, follow this suggested initialization sequence:

1.Write to Px_DIR to establish the individual pins as either inputs or outputs. (Outputs will drive the data that you specify in step 3.)

— For a complementary output, clear its P x_DIR bit.

For a high-impedance input or an open-drain output, set its P x_DIR bit. (Open-drain outputs require external pull-ups.)

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-ups. 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-ups are turned off.

For a standard I/O pin, clear its P x_MODE bit. In this mode, the pin is driven as defined in steps 1 and 3.

For a special-function signal, set its P x_MODE bit. In this mode, the associated peripheral controls the pin.

3.Write to Px_REG.

For output pins defined in step 1, write the data that is to be driven by the pins to the corresponding Px_REG bits. For special-function outputs, the value is immaterial because the peripheral controls the pin. However, you must still write to Px_REG to initialize the pin.

— For input pins defined in step 1, set the corresponding P x_REG bits.

Table 7-6 lists the control register values for each possible configuration. For special-function outputs, the Px_REG value is irrelevant (don’t care) because the associated peripheral controls the pin in special-function mode. However, you must still write to Px_REG to initialize the pin. For a bidirectional pin to function as an input (either special function or port pin), you must set Px_REG.

7-7

Page 152
Image 152
Intel Microcontroller, 80C196NU, 8XC196NP manual Bidirectional Port Pin Configurations