General-purpose I/O Lines
The EM2000 has 56 general-purpose I/O lines (GPIO0 - GPIO55). All lines are 3.3V, CMOS, 5V-tolerant lines. Maximum load current for each I/O line is 20mA. Fifty one of these lines are always available. Remaining five lines are located on the wireless add-on connector. This connector is facing the host PCB only on EM2000-...-A devices.
The simplified structure of one I/O line of the EM2000 is shown on the circuit diagram below. Each line has an independent output buffer control. When the EM2000 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 EM2000 also serve as inputs or outputs of special function modules, such as serial ports. 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 "Platform-dependent Programming Information inside the EM2000 platform documentation (TIDE, TiOS, Tibbo BASIC, and Tibbo C Manual).
Each I/O line has a weak pull-up resistor that prevents the line from floating when the output buffer is tri-stated.
Forty I/O lines are grouped into five 8-bit ports. To preserve compatibility with the EM1000 module, the grouping of I/O lines into ports is exactly the same as on the EM2000. Unfortunately, this preservation of compatibility has turned the ports of the EM2000 into "pseudo ports", meaning that 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.
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 EM2000 is about 7 times faster compared to the EM1000.
I/O line control is described in detail in the documentation for the I/O (io.) object found inside the TIDE, TiOS, Tibbo BASIC, and Tibbo C Manual.