
Functional Description
LatticeMico GPIO 5
Independent Input and Output Port Type For the independent input and
output port type, the input and output ports are separate unidirectional
buses.The number of input pins can be set independently of the number of
output ports. The PIO_DATA register is wide enough to manage the larger of
the “Input Width” or “Output Width.” The input and output bits overlap in the
PIO_DATA register, starting at the least-significant bit. The “Input Width”
PIO_IN ports and “Output Width” PIO_OUT ports are created for connection
to logic external to the GPIO block.
Tristate Port Type For the tristate port type, each PIO bit shares one device
pin for driving and capturing data. The direction of each pin is individually
selectable. An I/O pin becomes an input when the corresponding PIO_TRI
register bit is cleared, that is, 0. Whenever the WISHBONE RST_I signal is
asserted, the PIO_TRI register is cleared, forcing all PIO_IO pins to be inputs.
IRQ Generation
You can configure the LatticeMico GPIO to generate an interrupt request
(IRQ) on level-sensitive or edge-sensitive input conditions.
Level-sensitive – An IRQ is generated whenever a specific input is high
and interrupt requests are enabled for that input in the IRQ_MASK
register. The input pin should be held high until the interrupt condition is
cleared.
Edge-sensitive – An IRQ is generated whenever a specific bit in the edge
capture register is high and interrupt requests are enabled for that bit in
the IRQ_MASK register. The type of edge must be specified at platform
generation: positive edge, negative edge, or either edge. Clearing a bit—
that is, setting it to zero in the edge capture register—clears the
corresponding bit in the edge capture register. Setting a bit in the interrupt
mask register resets the corresponding bit in the edge capture register if it
was set.
Any I/O in a GPIO can cause an interrupt request. The IRQ_MASK register of
the GPIO defines which I/Os can cause an interrupt request.
When the IRQ mode is turned off, the IRQ_MASK register does not exist.
Figure 3 shows a bidirectional LatticeMico GPIO similar to that shown in
Figure 2 but with the ability to generate interrupt requests. The GPIO in
Figure 3 can generate interrupt requests as a signal switches from 0 to 1 or 1
to 0 (edge capture).
Note
The GPIO interrupt generation logic is synchronized to the WISHBONE clock.
In order to ensure that the interrupt generation logic can capture a 0 to 1 or 1
to 0 transition, the external logic driving the GPIO line must ensure that the 1
to 0 or 0 to 1 transition is valid for at least one WISHBONE clock. If the GPIO
line transitions, for example, from 1 to 0 and back to 1 before a WISHBONE
clock edge, then the interrupt will not be generated because the 1 to 0 edge
was not captured.