Файл: Embedded Controller Hardware Design (Ken Arnold, 2001).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 2662

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

122EMBEDDED CONTROLLER

Hardware Design

the address bus and each of the eight decoder outputs to a memory IC chip enable, one of the eight memory devices will be selected for any given ad­ dress. Decoders also have enable inputs that can be used to enable the outputs only for a selected address space such as memory or I/O. The example in Figure 5-6 shows an 8031 with eight program EPROMs.

Address Map

In order to describe the address decoding of memory and I/O clearly an address map (also referred to as a memory map) table is used to specify which devices respond to a particular range of addresses in a given address space. The purpose of an address map is to clearly define the range of addresses that each memory or I/O device occupies in the address space. A separate map is used for each address space in processors that have more than one address space. For example, the 8031 has a factory defined map of the internal data memory address space, another map for program memory, and a third for external data memory. It also helps to define which memory space any given device resides in. As an example, the address decoding table for Figure 5-6 is shown in Table 5-1:

Address Range

Address bits

Decoder Ouputs

Chip Select Active

(hex)

A15 A14 A13

76543210

for Memor y IC

0000 - 1FFF

0 0 0

11111110

EPROM 0

2000 - 3FFF

0 0 1

11111101

EPROM 1

4000 - 5FFF

0 1 0

11111011

EPROM 2

6000 - 7FFF

0 1 1

11110111

EPROM 3

8000 - 9FFF

1 0 0

11101111

EPROM 4

A000

- BFFF

1 0 1

11011111

EPROM 5

C000

- DFFF

1 1 0

10111111

EPROM 6

E000

- FFFF

1 1 1

01111111

EPROM 7

Table 5-1: Memory map for Figure 5-6.

The same decoding technique can be applied to I/O devices to select one of several devices. In the case of an I/O decoder connected to a processor with a separate I/O address space, the decoder’s enable input would be controlled by the CPU I/O control line. Whenever an I/O cycle occurs, the I/O device address is presented on the address bus and the I/O control line is activated. This causes one of the decoder outputs to go active and select an input or output port. In


123CHAPTER FIVE

CPU Bus Interface and Timing

the case of memory mapped I/O, the decoder outputs would go to both memory and I/O devices. An I/O address map is used to specify the location(s) in I/O address space that each device will respond to. The map may also specify if the location is read only, write only, or read/write. This is because I/O device addresses are not always read and write. As an example, an output port that drives some LEDs would be an output only or “write only” port. Microcon­ troller chips usually have some dedicated input bits and output bits as well as some general purpose I/O port bits implemented directly on the chip, which are usually accessible by reading or writing special register addresses. Micro­ processors and microcontrollers with external buses can also have memory mapped I/O. The example below shows a one bit input port and a 1-bit output port mapped into the external RAM space along with six 8Kx8 RAMs.

The example address map in Table 5-1 and decoder circuit in Figure 5-6 illustrate complete address decoding. That is, there is one device mapped to each block of addresses in such a way that all the addresses map to one and only one unique set of memory locations. Each of the eight memories containing eight kilobytes of memory maps to one of the eight regions of eight kilobytes. There are no unused addresses, and there are no duplications. If all possible addresses are decoded, but some are not used, then it is possible to expand the memory available by using the available memory address ranges for additional memory. If any device is decoded in such a way that it appears more than once in the address space, then it is referred to as partial address decoding. This derives from the fact that not all the address signals are used to determine which device should be enabled. This is often done to reduce the complexity of the decod­ ing circuits, at the

expense of future

8031

EN

7

6

expansion options.

74LS138

RD

+V

5

3:8 Decoder 4

3

In the address

A13

A

2

1

A14

B

0

decoder shown in

A15

C

D0

To RAM

SW1

Figure 5-7, the

3

Chip Select

Input Port

I/O addresses are

A13 ..15

+V

Address

16

partially decoded,

A0 ..15

A0 ..15

Output Port

resulting in a

WR

To RAM

C

range of addresses

RD

OE

LED

that enable a

D0

D

Q

WR

To RAM

WE

single device

(the I/O port).

Figure 5-7: Memory mapped I/O in the 8031 external memory space.


124EMBEDDED CONTROLLER

Hardware Design

Note also that two separate address ranges have been used, one for the input port and one for the output port. In practice, it is possible to have the input and output ports respond to the same address by using the read line for input cycles, and the write line for outputs.

Address Range

Address bits

Decoder Ouputs

Active Select:

(hex)

A15 A14 A13

76543210

Memor y I/O

0000 - 1FFF

0 0 0

11111110

RAM 0

2000 - 3FFF

0 0 1

11111101

RAM 1

4000 - 5FFF

0 1 0

11111011

RAM 2

6000 - 7FFF

0 1 1

11110111

RAM 3

8000 - 9FFF

1 0 0

11101111

RAM 4

A000

- BFFF

1 0 1

11011111

RAM 5

C000

- DFFF

1 1 0

10111111

Output Port

E000

- FFFF

1 1 1

01111111

Input Port

Table 5-2: External data memory map (8031 external memory space).

The decoder will select the input port at any address in the range E000 through FFFF hex. That means that the single input port bit takes up 8K address loca­ tions, all reading the same input port. This decoding technique is partial address decoding because only the three most significant address bits are decoded for this input port, and the rest of the address lines are effectively “don’t cares.” This may seem wasteful of address space, but it reduces the amount of decoding circuitry when it is not necessary to decode all the unique addresses individually. The memory map of the external data memory address space is shown in Table 5-2.

Chapter Five Problems

1.If the design of Figure 5-7 needs to be changed to eliminate the duplication of addresses caused by partial address decoding, how many additional input signals would be required for the decoder?

2.The 8031 CPU has 16 address lines. How much external memory can be attached to it without resorting to any memory extension mechanism?

3.If all bits of Port 1 on an 8031 are used to select external data memory in one of 256 “banks,” what is the maximum amount of external data memory that can be accessed?

4.What is the answer to life, the universe, and everything?


6

CHAPTER SIX

125

A Detailed

Design Example

In this chapter, we will take a detailed look at the design and analysis of a simple microcontroller project. This chapter will illustrate the interactive nature of the design process. First, the preliminary design is analyzed for limitations and violations of the timing requirements for the various chips. Then modifications and additions to the design are made to improve the performance based on the analysis. The modified design is then verified for conformance to the various component specifications. This iterative process begins with a simple block diagram showing the components of interest and progresses to detailed timing diagrams, specifications, and timing analysis.

The Central Processing Unit (CPU)

The process of designing an embedded microcomputer system is mostly independent of the particular CPU that is used. The example design of this chapter is a relatively simple one that illustrates the design and analysis process in enough detail to show what needs to be done. Because the Intel 8031 microcontroller design has a simple bus interface, has brief timing specifications, uses SRAM, and incorporates relatively simple I/O on chip, it will be used to illustrate the critical design and analysis processes. Once the complete process is understood with this simple CPU, more advanced designs can be addressed with comparative ease.

The 8031 processor is a Harvard architecture with a multiplexed address and data bus. There are three address spaces: internal RAM, external data RAM, and external program ROM. The external program ROM and data RAM are