First page Back Continue Last page Overview Graphics

Example: Configuring 68HC12 port A


In this example, we practice the configuration of an I/O port of the 68HC12. The address decoding circuit for each port is already built into the microcontroller. There are four configuration registers for each port.
The data direction register – This register is used to configure the port direction. This register has 8 bits. Each bit determines the direction of the corresponding I/O bit. The user can configure each bit individually as input or output.
The data register – This register connects to the microprocessor pins where data is read (if configured as an input port) or written (if configured as an output port). This register has 8 bits. Each bit is either an input or output depends on how the data direction register is configured.
The pull up register - This register allows the user to specify whether an internal pull up or external pull up is to be used. External pull ups can provide higher driving power but need additional external circuitry.
The Reduced Drive of I/O lines – This register is used only when internal pull up is selected. It allows the user to specify whether the output line should provide full power or reduced power. If reduced power is selected, the port switching time is longer.

Detailed information on these registers can be found in the data sheets for the specific microprocessor.