About the Input/Output Ports of a Microcontroller
In a microcontroller, input/output (I/O) ports are indispensable and represent one of the most fundamental functional blocks. From the perspective of microcontroller software, I/O ports are relatively easy to operate. However, although they are commonly referred to simply as I/O ports, their configurations and characteristics vary widely. Using them without a proper understanding can lead to unexpected problems.
The following section describes the input/output ports of microcontrollers, which are generally implemented using CMOS ICs.
1. Port Configuration
The differences in configuration are examined by separating them into output ports and input ports.
Output Ports
- Complementary Output Circuit
Also called a complementary output circuit, this type of port outputs either a HIGH-level signal using a P-channel transistor or a LOW-level signal using an N-channel transistor.
Example of a Complementary Output Port Circuit - Open-Drain Output Circuit
In a complementary output circuit, both P-channel and N-channel transistors are used to output either a HIGH-level or LOW-level signal. In contrast, an open-drain type circuit is configured to output only a HIGH-level signal using a P-channel transistor, or only a LOW-level signal using an N-channel transistor.
An output circuit that uses only P-channel transistors is called a P-channel open-drain, while one that uses only N-channel transistors is called an N-channel open-drain.
Example of an N-Channel Open-Drain Circuit
Input Ports
-
Gate Input Circuit
This structure directly transmits signals from an external source to the microcontroller's input buffer*1. If no external voltage is applied to the input port, the input terminal of the buffer becomes floating (in an undefined state), which may result in excessive current flow.
Example of a Gate Input Port Circuit *1 In actual circuits, a protective resistor is inserted in the input signal line as shown above.
-
Input Circuit with Pull-Up/Down Resistors
For input ports, the microcontroller internally connects the port to either the power supply or ground through a resistor, keeping the port state at HIGH level or LOW level. Thanks to this resistor, even when no external voltage is applied to the input port, the input buffer does not become floating, and there is no risk of excessive current flow.
However, if a LOW-level signal is applied to a port that has a resistor connected to the power supply (pull-up resistor), or if a HIGH-level signal is applied to a port that has a resistor connected to ground (pull-down resistor), current will continuously flow through the resistor, resulting in power consumption.
Example of an Input Port with Pull-Up Resistor
2. Port Characteristics
Next, the differences in the characteristics of input ports are described.
Input Characteristics
-
Input Circuit
Depending on the voltage applied to the input port, the microcontroller captures either a HIGH-level or LOW-level signal. However, the threshold voltage is fixed at a single level. This allows the circuit to respond to fast signal transitions (rise and fall), but it is more susceptible to noise in the input signal, which may result in unintended inputs or unexpected input interrupts.
Example of Input Waveform and Data Captured by the Microcontroller (Standard Input Circuit) -
Schmitt Trigger Input Circuit
In the previously described input circuit, the threshold voltage is fixed at a single level, and the value captured by the microcontroller changes depending on whether the applied voltage is above or below that threshold. In contrast, a Schmitt trigger input circuit has a hysteresis characteristic *2, meaning the threshold differs between the rising and falling edges of the voltage.
While this design slightly reduces responsiveness to external input signals, it is more resistant to noise compared to a standard input circuit. The decrease in responsiveness is minimal, and for microcontroller input ports operating at clock speeds below several tens of MHz, using a Schmitt trigger input circuit to improve noise immunity offers a clear advantage.
Example of Input Waveform and Data Captured by the Microcontroller (Schmitt Trigger Input Circuit) *2 Hysteresis characteristic refers to a property where a state changes not only based on the current applied force but also depends on forces applied in the past.
Most models in Epson's S1C17/31 Family feature I/O ports that support both input and output functions. These ports allow software-controlled switching between complementary/open-drain output and input circuits with pull-up/pull-down resistors. Furthermore, for input ports, Schmitt trigger input is the standard design, providing improved connectivity with external devices and enhanced noise immunity.
