an265.pdf

Using MAX 3000A Devices as
a Microcontroller I/O
Expander
August 2003, Ver 1.0
Application Note 265
Introduction
Many microcontrollers and microprocessors limit I/O ports and pins to
conserve pin counts and reduce package sizes. For many microcontroller
(e.g., PIC, 8051, and SX) or microprocessor based-systems, the system
design requires more I/O ports or pins than the microcontroller provides.
To increase the number of I/O pins without changing the microcontroller,
I/O expansion provides a solution. With up to 208 I/O pins and
MultiVoltTM I/O capability, Altera® MAX® 3000A devices allow you to
implement microcontroller I/O expansion in microcontroller- or
microprocessor-based systems. This application note explains how to
implement a microcontroller I/O expander in MAX 3000A devices.
Advantages of
Using MAX
3000A Devices
A key advantage of using MAX 3000A devices as a microcontroller I/O
expander is the integration of logic functions across your entire board.
The flexibility of a programmable device means that not only can the I/O
expansion function be implemented, but other functions can be
integrated such as LED drivers or bus-bridging logic. This integration
allows you to reduce component count across the board, minimizing cost
and maximizing board space efficiency.
Another advantage in using MAX 3000A devices is the MultiVolt I/O
capability which enables MAX 3000A devices to interface to 5.0-V, 3.3-V,
and 2.5-V I/O pins. This capability allows you to implement voltage-level
shifting to interface older 5.0-V devices with newer 3.3-V or 2.5-V devices
or microcontrollers.
The large numbers of I/O pins on MAX 3000A devices make it an ideal
device for microcontroller I/O expansion. Table 1 shows the maximum
user I/O pins available in MAX 3000A devices. The maximum I/O pins
available are 208 which translates to 26, 8-bit ports. Additionally, insystem programmability (ISP) means that these features come with the
flexibility of reprogrammability on the board.
Table 1. Maximum User I/O Pins in MAX 3000A Devices
Maximum User
I/O Pins
Altera Corporation
EPM3032A
EPM3064A
EPM3128A
EPM3256A
EPM3512A
34
66
98
161
208
1
Preliminary
Using MAX 3000A Devices as a Microcontroller I/O Expander
Implementing a
Microcontroller
I/O Expander in
MAX 3000A
Devices
The I/O expander design example includes four ports (A, B, C, and D)
which can be independently programmed as I/O ports. Each port is 8 bits
wide and is bidirectional, becoming an input port when tri-stated. You
can connect the microcontroller unit (MCU) port to or from any port
(A, B, C, or D) to perform read and write operations. Figure 1 shows the
block diagram of the design example for the microcontroller I/O
expander.
Figure 1. Block Diagram for Microcontroller I/O Expander Design Example in MAX 3000A Devices
8
Port A
8
8
8
Input
Data
Latch
8
8
8
Port B
8
2
MCU Port
2
I/O Ports
4
8
I/O Setting
Data Register
4
I/O Ports
Port C
8
8
Output
Data
Latch
8
8
8
8
Port D
8
CS
2
Preliminary
RST
CONF
LOAD
WR
RD
MODE
Altera Corporation
Using MAX 3000A Devices as a Microcontroller I/O Expander
Table 2 lists all the functions of the input and output pins.
Table 2. Input & Output Pins in a Microcontroller I/O Expander Example Design
I/O Name
Type
Description
Active
8-bit bidirectional data lines that interface with the MCU
data bus. The 8-bit data can be written into or read out
of the microcontroller I/O expander on the WR and RD
signals. Configuration data is also transmitted through
this port. The MODE signal determines whether the
MCU port is a data or address bus.
-
MCU port
Bidirectional
CS
Input
Input signal to select the device.
Low
RST
Input
Input signal to reset the device and all internal
registers.
Low
CONF
Input
This control signal stores the sddress[5..0] from
the MCU port on the falling edge of CONF into the
configuration registers. Data on address[7..6] is
ignored. (The operation will be discussed later in this
application note.)
Low
LOAD
Input
This control signal stores the address[1..0] from
the MCU port on the falling edge of LOAD into
configuration registers. Data on address[7..2] is
ignored. (The operation will be discussed later in this
application note.)
Low
WR
Input
Input signal that causes the data on the MCU port to be
written to the enabled port (A, B, C, or D).
Low
RD
Input
Input signal that enables the data bus transfer to the
MCU port from the enabled port (A, B, C, or D).
Low
MODE
Input
Tri-states the MCU port when this signal is high. The
MCU port setting (input or output) depends on the
configuration registers when MODE is low.
-
Port A
Bidirectional
8-bit, general-purpose I/O port that can be
programmed to either output or input mode.
-
Port B
Bidirectional
8-bit, general-purpose I/O port that can be
programmed to either output or input mode.
-
Port C
Bidirectional
8-bit, general-purpose I/O port that can be
programmed to either output or input mode.
-
Port D
Bidirectional
8-bit, general-purpose I/O port that can be
programmed to either output or input mode.
-
Altera Corporation
3
Preliminary
Using MAX 3000A Devices as a Microcontroller I/O Expander
Functional
Description
The microcontroller I/O expander operates as a slave that sends and
receives data through the MCU port. Data is sent through the I/O
expander at the high-to-low transition of the WR signal (with CS set to
low) and received at the high-to-low transition of the RD signal (with CS
set to low).
Write Mode
In write mode, the selected port (A, B, C, or D) is configured as an output
port and the MCU port as an input port. Therefore, when the RW signal
changes from high to low (with CS set to low), the data from the MCU
port is written into the output data latch of the selected port.
Read Mode
In read mode, the selected port (A, B, C, or D) is configured as an input
port and the MCU port as an output port. When the RD signal changes
from high to low (with CS set to low), the data from the selected port is
written into the input data latch of the MCU port.
1
During read and write operation, the MODE signal control pin
must be set to low. See “Design Verification” on page 6 for an
example of read and write operations.
Configuration of the Microcontroller I/O Expander
Configuration of the microcontroller I/O expander is used to determine
whether the port is input or output and enabled or disabled. Activation
of the new configuration occurs with a single configuration pulse of the
CONF signal.
Data controlling the microcontroller I/O expander is stored in a set of
6-bit registers. Data to be written into these registers, consisting of 4 bits
for I/O port configuration data and 2 bits for the enabled port address
data, is placed on the input address bus (MCU port) with the MODE signal
set to high and the CS signal set to low. Input data is stored in the
configuration registers at the high-to-low transition of the CONF signal
input pin with the CS signal set to low. This transition causes the state of
the microcontroller I/O expander to be set to the selected configuration.
When the LOAD signal is asserted from high to low (with CS set to low),
only 2 bits of the enabled port address data (bit1 and bit0) are stored
in the configuration registers. Use the LOAD signal when you need to
select the enabled port to perform read or write operation instead of
configuring the ports.
Figure 2 shows the functionality of every bit in the address bus during
configuration mode.
4
Preliminary
Altera Corporation
Using MAX 3000A Devices as a Microcontroller I/O Expander
Figure 2. I/O Expander Address Bus Configuration Function
A7
A6
A5
A4
A3
A2
bit 7-6:
A7:A6: No functionality
bit 5:
A5: Port D configuration bit
0 = Configured as input
1 = Configured as output
bit 4:
A4: Port C configuration bit
0 = Configured as input
1 = Configured as output
bit 3:
A3: Port B configuration bit
0 = Configured as input
1 = Configured as output
bit 2:
A2: Port A configuration bit
0 = Configured as input
1 = Configured as output
bit 1-0:
A1:A0: Port Address
A1
A0
Table 3 shows the address contents to enable the particular I/O ports.
Table 3. Port Addresses
A1:A0
Port
00
A
01
B
10
C
11
D
MCU port direction, input or output, cannot be directly configured by the
user. It is configured internally by the selected enabled port. For example,
if the enabled port is in input mode, the MCU port is set to an output
mode. However, you can use the MODE signal control pin to tri-state the
MCU port so that it becomes an input port, allowing you access to the
configuration registers.
Reset mode is also supported in the microcontroller I/O expander
reference design. When the RST signal is asserted (with CS set to low), the
contents of all registers are reset to zero and the entire I/O expander is in
its initial state, where all the ports (including the MCU port) are set to
input mode.
Altera Corporation
5
Preliminary
Using MAX 3000A Devices as a Microcontroller I/O Expander
MAX 3000A Implementation
The microcontroller I/O expander design example was targeted to
128-macrocell MAX 3000A devices (EPM3128ATC100) using the
Quartus® II software. The design utilization in the 128-macrocell
MAX 3000A device is shown in Table 4. The data in Table 4 shows that
there is sufficient resources (I/O pins and macrocells) remaining in the
device for the implementation of the other logic in the system.
Table 4. Microcontroller I/O Expander EPM3128A Utilization
Resource
Available
Used
Utilization (%)
Macrocells
128
67
52
Flipflops
128
10
7
I/O Pins
80
51
63
Design Verification
Design verification of a microcontroller I/O expansion was accomplished
by using the Quartus II software. The design was verified both in
functional and timing simulation in MAX 3000A devices
(EPM3128ATC100). Figures 3 and 4 show the timing simulation of the
microcontroller I/O expansion during read and write operation.
6
Preliminary
Altera Corporation
Using MAX 3000A Devices as a Microcontroller I/O Expander
Figure 3. Microcontroller I/O Expansion Write Mode Timing Simulation
Configure the Microcontroller
I/O Expander
The High-to-Low Transition of the WR Signal
Creates New Output Values
Change the Enabled Port
The WR Signal Creates New
Output Values
With all the I/O pins in tri-state mode, each port is initialized. After
initialization, Port A and Port B are configured as output, Port C and
Port D are configured as input, and Port B is enabled for write operation.
When the WR signal asserts a high-to-low transition, the MCU port data
(146) is latched to the output Port B.
In the last section of simulation, Port A is enabled at the high-to-low
transition of the LOAD signal. When the WR signal asserts a high-to-low
transition, the MCU port data (108) is latched to the output Port A.
Altera Corporation
7
Preliminary
Using MAX 3000A Devices as a Microcontroller I/O Expander
Figure 4. Microcontroller I/O Expansion Read Mode Timing Simulations
The RD Signal Creates New
Output Values
Configure the Microcontroller
I/O Expander
Change the Enabled Port
The High-to-Low Transition of the WR Signal
Creates New Output Values
With all the I/O pins in tri-state mode, each port is initialized. After
initialization, all ports (A, B, C, and D) are configured as input and Port C
is enabled for read operation. When the read signal asserts a high-to-low
transition, the Port C data is latched to the MCU port.
While in the last part of the simulation, Port D is enabled at the high-tolow transition of the LOAD signal. When the RD signal asserts a high-tolow transition, the Port D data (146) is latched to the MCU port.
8
Preliminary
Altera Corporation
Using MAX 3000A Devices as a Microcontroller I/O Expander
Microcontroller I/O Expander Applications
Figures 5 shows how to increase the microcontroller’s I/O ports using the
I/O expander. This microcontroller I/O expander can be targeted or
modified to target to any 8-bit microcontroller (e.g., PIC and 8051).
Figure 5. Application of Microcontroller I/O Expander
Microcontroller
I/O Expander
RD output
8
RD
Port A
WR output
WR
CS output
CS
8
Port B
LOAD output
LOAD
CONF output
CONF
8
Port C
MODE output
MODE
RST output
8
RST
Port D
8
Microcontroller I/O Port
Conclusion
Altera Corporation
MCU Port
With up to 208 I/O pins and MultiVolt I/O capability, Altera MAX 3000A
devices allow you to implement microcontroller I/O expansion in a
single device. MAX 3000A devices enable you to design custom
microcontroller I/O expanders with additional features other than the
example provided in this application note.
9
Preliminary
Using MAX 3000A Devices as a Microcontroller I/O Expander
101 Innovation Drive
San Jose, CA 95134
(408) 544-7000
www.altera.com
Applications Hotline:
(800) 800-EPLD
Literature Services:
[email protected]
10
Preliminary
Copyright © 2003 Altera Corporation. All rights reserved. Altera, The Programmable Solutions Company,
the stylized Altera logo, specific device designations, and all other words and logos that are identified as
trademarks and/or service marks are, unless noted otherwise, the trademarks and service marks of Altera
Corporation in the U.S. and other countries. All other product or service names are the property of their respective holders. Altera products are protected under numerous U.S. and foreign patents and pending
applications, maskwork rights, and copyrights. Altera warrants performance of its semiconductor products
to current specifications in accordance with Altera's standard warranty, but reserves the right to make changes to any products and services at any time without notice. Altera assumes no responsibility or liability
arising out of the application or use of any information, product, or service described
herein except as expressly agreed to in writing by Altera Corporation. Altera customers
are advised to obtain the latest version of device specifications before relying on any published information and before placing orders for products or services.
Printed on recycled paper
Altera Corporation