8XC196MC, MD, MH USER’S MANUAL

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 6-8 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.

6-10

Page 157
Image 157
Intel 8XC196MH, 8XC196MD manual 8XC196MC, MD, MH USER’S Manual