First page Back Continue Last page Overview Graphics
Example: Configuring 68HC12 port A
The hardware circuitry for the I/O ports is included in the 68HC12 microcontroller.
The 68HC12 has four memory addresses related to configuration of and access to port A.
- DDRA --port A data direction register (address $0002)
- PORTA -- port A data register (address $0000)
- PUPCR, bit 0 -- Pullup port A enable (address $000C)
- RDRIV, bit 0 -- reduced drive of I/O lines (address $000D)
If reduced power is selected, port switching time is longer.
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.