General Purpose I/O Lines

The EM2001 has 56 general-purpose I/O (GPIO) lines (GPIO0 ~ GPIO55). All lines are 3.3V, CMOS, and 5V-tolerant. The maximum load current for each I/O line is 10mA. Fifty one of these lines are always available. The remaining five lines are located on the wireless add-on connector and can be used if no wireless add-on module is installed.

The simplified structure of one I/O line of the EM2001 is shown in the circuit diagram below. Each line has an independent output buffer control. When the EM2001 powers up, all its I/O lines have their output buffers tri-stated (in other words, all I/O lines are configured as inputs). You need to explicitly enable the output buffer of a certain I/O line if you want this line to become an output.

Many I/O lines of the EM2001 also serve as inputs or outputs of special function modules, such as serial ports. The majority of those lines need to be correctly configured as inputs or outputs — this won't happen automatically. Several lines — such as TX and RX lines of the serial port when in the UART mode — are configured as outputs and inputs automatically when the serial port (or some other hardware block) is enabled. For details, see the EM2000 programming platform.

Each I/O line has a weak pull-up resistor that prevents the line from floating when the output buffer is tri-stated.


A circuit diagram of an EM2001 GPIO line.

8-Bit Ports

Forty I/O lines are grouped into five 8-bit ports. To preserve compatibility with the EM1001, the grouping of I/O lines into ports is exactly the same. Unfortunately, this preservation of compatibility has turned the ports of the EM2001 into "pseudo ports," meaning that the GPIO lines of these ports actually belong to several different physical ports of the onboard microcontroller. As a result, port operations such as io.portset, io.portget, or io.portstate do not access port pins in perfect unison. In port operations, writing or reading of some lines will happen sooner than writing or reading of other lines. This "dissonance" is very small and will not matter for most applications, but do keep in mind that it does exist.

The port mapping arrangement is different for different ports, so their performance varies slightly as well. Ports P0 and P1 are about 10% slower than P2, P3, and P4. In most cases, this difference is negligible, especially considering that GPIO line and port manipulation on the EM2001 is about seven times faster compared to the EM1001.  


I/O line control is described in detail in the documentation for the io. object.


General Purpose I/O Lines

8-Bit Ports