Ask Larry

On occasion our technical support department will receive questions from customers asking about external I/O. I remember writing about this topic several years ago and I think it is time for me to take another crack at it.

External I/O is essentially a method of increasing the number of parallel ports on a Rabbit using external logic. This is not a feature that is unique to Rabbit as there have been I/O chips for microprocessors almost since the beginning of the technology. The Intel 8255 and the Motorola 6820 are two examples of early ICs. The Rabbit RIO® is one of the newest.

This column will show how to set up external I/O in a Rabbit 4000 (this will also work for the Rabbit 5000). The attached program shows the minimum required steps to get it going. There is code in the sample for both C and assembly language.

The external I/O feature of the Rabbit allows up to 64 KB of “external” I/O space. That space is divided into 8 KB pages. The page number is determined by the upper three bits of the address you are accessing. The bits are decoded by the processor and are used to select which I/O strobe is activated for the I/O operation. The program must set up the I/O strobe as shown in the sample program. The strobes are available on almost all parallel ports starting with port C, except for the Rabbit 2000 and Rabbit 3000 which have to use port E.

The specific operation of the I/O strobe is controlled by the IBnCR, where “n” represents the bank number as well as the bit in the parallel port selected for the I/O strobe. The operation of the I/O strobe can be any of the following:

  • Chip select (default)
  • I/O write
  • I/O read
  • I/O write or I/O read

Other bits in this register control the following features:

  • Number of wait states used to generate the I/O strobe pulse width, default = 15
  • Write-enable, if this bit is not set the I/O write will not be generated
  • Phase of the I/O strobe, default is for the I/O strobe to be normally high

There are other features that you should investigate if you are going to use external I/O. You need to read the chapter in the appropriate Rabbit Microprocessor User’s Manual.

Other control signals generated by external I/O activity are:

  • /IOWR
  • /IORD
  • /BUFEN

Note that it usually takes a minimum of 11 signals to implement – this number of signals does not make use of the address lines. Whenever the auxiliary external I/O is enabled it will use parallel port A for the data bus and at least six bits from parallel port B for the address bus. This is fixed by the logic within the Rabbit and cannot be changed. It is possible to use the external I/O without using the parallel ports but you have to have access to the memory data and address buses directly off the processor. This paper only discusses auxiliary external I/O. Using parallel port B as the address bus obviously limits you to eight pages of 256 bytes each.

Here is a block diagram I have used before that shows the basic connections for external devices:

Basic Connections

Figure 1. Basic Connections

Depending on the specific application, the number of signals from the Rabbit could be less than what are shown here. The number of address bits shown is only available if you have access directly to the memory bus of the Rabbit. Otherwise, the most you can get is eight bits via parallel port B.

Here is another diagram which is closer to a schematic:

Rabbit Micorprocessor to Discrete Logic

Figure 2. Rabbit Micorprocessor to Discrete Logic
Easiest to understand but least efficient
Note: Each port E bit should have a pull-up resistor

This “schematic” does not make use of port B as the address bus - it uses multiple bits from port E as I/O strobes instead. Using port B would make the circuit more efficient if the bits were used as inputs to a decoder device (like a ‘138) along with a single bit from port E as the I/O strobe.

Here are logic analyzer pictures of external I/O writes with varying conditions. In all of these pictures, Channel 0 is the I/O strobe and Channel 1 is PA0 (I did not bother to change the displayed names of the signals). All of these tests were run on an RCM4200 which has a CPU clock frequency close to 59 MHz.

The conditions and results for the following picture are:

  • The loop is written in C
  • Number of wait states is 15
  • Logic analyzer sample frequency = 200 MHz (5ns sample time)
  • I/O strobe pulse width (PE0) = 290ns (time from curser T to curser X)
  • I/O period = 4.28us (time from curser T to curser Y)
  • The delay between /IOWR and /IORD is 1.175us (time from curser T to curser Z)
Eternal I/O Writes

Figure 3. Eternal I/O Writes

Observations:

  • The I/O period contains two I/O strobes from PE0. This is because there are two I/O operations occurring in each period – one write and one read
  • The /IOWR and /IORD are “surrounded” by the /CS signal. This is more obvious in the final picture below

The conditions and results for the following picture are:

  • The loop is written in assembly language
  • Number of wait states is 15
  • Logic analyzer sample frequency = 500 MHz (2ns sample time)
  • I/O strobe pulse width (PE0) = 290ns (time from curser T to curser X)
  • I/O period = 1.318us (time from curser T to curser Y)
  • The delay between /IOWR and /IORD is 646ns (time from curser T to curser Z)
Eternal I/O Writes

Figure 4. Eternal I/O Writes

The conditions and results for the following picture are:

  • The loop is written in assembly language
  • Number of wait states is 1
  • Logic analyzer sample frequency = 500 MHz (2ns sample time)
  • I/O strobe pulse width (PE0) = 52ns (time from curser T to curser X)
  • I/O period = 854ns (time from curser T to curser Y)
  • The delay between /IOWR and /IORD is 410ns (time from curser T to curser Z)
Eternal I/O Writes

Figure 5. Eternal I/O Writes

External I/O Program Code

- Larry C.

Larry Cicchinelli is Rabbit’s Technical Support Manager. He has 30 years of embedded experience, and is considered one of the foremost authorities on Rabbit products. Larry and his staff offer comprehensive technical support to Rabbit customers.

Submit your questions for Larry via email at AskLarry@rabbit.com

Read more Ask Larry Answers