16.4 Mode 1 Digital I/O With Handshaking

In Mode 1, a Latch input and an Acknowledge output signal are provided for handshaking operation. This allows the external circuit to tell the board when new input data is ready or when it has accepted the current output data, and it allows the board to tell the external circuit when it has read the current input data and when new output data is ready. Only Port A may be operated in Mode 1. In all cases, the starting / resting conditions are Latch input = low and Acknowledge output = low

Mode 1, Input, Non-Interrupt Operation

When the Latch input is brought high, Port A will latch the data on the I/O header pins, and the Acknowledge output will go high. The latches are D type flip-flops with positive-edge-triggered clocks, so just the rising edge of the Latch signal is used.

If a second rising edge occurs on the Latch input before the board reads the current data, the current data will be overwritten by whatever is then appearing on the input pins. The register’s input latches are reset upon reading the register.

After the register has been read, the Acknowledge signal goes low to indicate that data has been accepted and new data may be latched.

Mode 1, Output, Non-Interrupt Operation

When data is written to Port A in mode 1 output, the Acknowledge output will go high, indicating that new data is available. When the Latch input is driven high by the external circuit, the Acknowledge output will go low. The external circuit may drive the Latch input low anytime after this happens.

Mode 1, Input, Interrupt Operation

When the Latch input is brought high, Port A will latch the data on the I/O header pins, the Acknowledge output will go high, and an interrupt request will be generated. When the data has been read from within the interrupt routine, the Acknowledge signal goes low to indicate that new data may be latched.

The interrupt routine is responsible for clearing the interrupt request signal from the board by writing a 1 to bit 3 of Base + 8

Mode 1, Output, Interrupt Operation

When data is written to Port A in mode 1 output, the Acknowledge output will go high, indicating that new data is available. After the external devices latches the data, it drives the Latch input high, causing the Acknowledge output to go low and a new interrupt request to be generated. The interrupt routine then writes new data to Port A to restart the cycle.

Note that in this mode the program should write the first output value to Port A prior to the first interrupt being generated, so that the data is available to the external circuit before the first low-to-high Acknowledge transition. At the last interrupt, the program has no more data and simply terminates the operation.

Last updated