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

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

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

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

Добавлен: 13.06.2025

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

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

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

32EMBEDDED CONTROLLER

Hardware Design

The lower 128 byte half of the 256 byte internal data memory address space contains four blocks of eight CPU registers, R0-7. In the 8032 CPU, the upper 128 bytes of the internal data memory address space are shared between data memory and the SFRs, depending upon the address mode. The upper 128 bytes of data memory must be accessed using the indirect register 0/1 (@R0 or @R1 operands) or stack accesses, and all other references to addresses of 128 or higher will access the SFRs. All registers except the program counter and the four 8-register banks reside in the special function register address space. These memory mapped registers include arithmetic registers, pointers, I/O ports, and registers for the interrupt system, timers and serial channel. There are 128 bit locations in the SFR address space that are addressable as bits. The 8031 contains 128 bytes of internal data RAM and 20 special function registers (SFRs), while most other processor family variants include an additional 128 bytes of internal data memory overlapped with the SFR addresses.

8051 CPU Hardware

The 8051 is classified as an 8-bit machine, since the internal ROM, RAM, special function registers, arithmetic/logic unit and external data bus are each eight bits wide. The 8031 is identical to the 8051, except that it does not have any internal program ROM. The 8051 performs operations on bit, nibble, byte and double-byte data types. It excels at bit handling since data transfer, logic and conditional branch operations can be performed directly on the bit addressable SFRs.

This section describes the hardware architecture of the 805l CPU. A detailed 8051 functional block diagram is displayed in Figure 2-7.

Internal

Data

Control

Instruction

Memory

Unit

Register

ACC

B

PSW

Program

I/O Ports

Counter

Timers

Internal

Dater Pointer

Program

Stack Pointer

Arithmetic

Memory

ROM

G.P. Memory

Logic

Registers

Unit

Port 3

Port 2

Port 1

Port 0

Figure 2-7: 8051 CPU block diagram.


33CHAPTER TWO

Microcontroller Concepts

Control Unit

Each program instruction is decoded by the control unit, which is also called the instruction decoder. This unit generates the internal signals that control the functions of all the other units within the CPU section. All instructions are fetched from the program memory ONLY. Instructions can be fetched from either the internal program memory (for those devices which possess one)

or from external program memory. Instruction fetch operations are indicated when the CPU activates (lowers) the /PSEN line (NOT program strobe enable). A program memory fetch cycle lasts as long as /PSEN stays low. External program memory must only drive the data bus with the addressed instruction while /PSEN is low.

Program Counter

This is the pointer to the next instruction to be executed. The 16-bit program counter (PC) controls the sequence in which the instructions stored in program memory are executed.

Instruction Register

This is the register that contains the instruction that is currently being executed.

Internal Program Memory

The 8051 family has 16 address lines, and can directly address 216 = 64 kilobytes of program memory. The original 8051 has 4 kilobytes of program memory resident on-chip, the 8031 has no on-chip program memory, and the 8052 has 8 kilobytes of program memory. Other variants of the family are available with 1 to 64 kilobytes of various types of non-volatile program memory built in. The 64 kilobyte program memory address space is composed of a combination of internal and external program memory (external program memory only on the 8031 and 8032). When external program memory is accessed, and the processor is fetching an instruction to be executed, the external program read cycle is signaled by activating the CPU’s /PSEN control line. The MOVC instruction also activates /PSEN to enable reading the code memory

34 EMBEDDED CONTROLLER

Hardware Design

into the accumulator for accessing lookup tables

Program

(Code)

and other unchanging data stored in the program

Memory

FFFF

memory space. Figure 2-8 shows a program

External

memory map.

Figure 2-8:

Program

Memory

Program

/PSEN

The processor can fetch instructions from internal

memory map.

Pulses

or external program memory. There is a control

Low

MOVC a

input pin, /EA (external access), which forces all

2000

instructions to be fetched from the external

1FFF

Internal

program memory when the pin is pulled low.

Program

Memory

If the /EA pin is pulled high, then the processor

Reset Vector: 0000

will fetch instructions from any available internal

program memory. When the processor first powers up and receives a reset signal, it begins by executing the instruction at location 0000 in program memory. When the processor fetches instructions from external program memory, it puts the instruction address out on the address bus, pulses the /PSEN (program strobe enable) pin low to enable the external program memory to place the instruction on the data bus to the processor.

The generic part numbering scheme is as follows:

8xxx: NMOS logic

8xCxx: CMOS logic

803x: No internal program memory

805x: Factory programmed internal ROM program memory

87xx: Internal user programmable EPROM program memory

89xx: Internal flash EPROM program memory

8xx1: 4 kilobyte internal program memory, 128 byte internal RAM

8xx2: 8 kilobyte internal program memory, 256 byte internal RAM

For example, the 80C32 used as the standard processor in the SDK board is a CMOS part with no internal program ROM, and 256 bytes of internal data RAM.

Internal Data Memory

Figure 2-9 shows the data memory spaces in the 8051. The internal data RAM provides a convenient 128 byte scratch pad memory that includes the register


35 CHAPTER TWO

Microcontroller Concepts

banks, SFRs, and general-purpose data storage. The programmer (or compiler) may also use this scratch pad memory for storing intermediate calculations on a temporary basis. The 8031 contains a 128 byte internal data RAM (addresses 0-7Fh, which includes registers R0-R7 in each of four banks), in addition to the memory-mapped special function register (locations 80-FFh). The 8032 has an additional 128 bytes of internal data RAM also at locations 80-FFh, which can only be accessed by using indirect register addressing (@R0, @R1) and the stack. The lower 128 byte half of the 256 byte internal data memory address space contains four blocks of eight CPU registers, R0-7. In the 80x2 CPU, the upper 128 bytes of the internal data memory address space are shared between data memory and the SFRs, depending upon the address mode. The upper 128 bytes of data memory must be accessed using the indirect register 0/1 (@R0 or @R1 operands) or stack accesses, and all other references to addresses of 128 or higher will access the SFRs. All registers, except the program counter and the four 8-register banks, reside in the special function register address space. These memory mapped registers include arithmetic registers, pointers, I/O ports, and registers for the interrupt system, timers and serial channel. There are 128 bit locations in the SFR

address space that are address-

External

able as bits. The 8031 contains

Data

Memory

128 bytes of internal data

Figure 2-9: Data memory

FFFF

RAM and 20 special function

address spaces in the 8051.

registers (SFRs), while most

External

other processor family variants

Internal

Special

Data

Memory

include an additional 128 bytes

Data

Function

Memory

Registers

/RD

of internal data memory over-

See below

See separate

or

address map

/WR

lapped with the SFR addresses.

FF

FF

Pulse

80

MOV @R0/1

80

MOV 80-FF

Low

7F

MOV 00-7F

Some SFRs

MOVX a

00

are also bit

0000

Data Memory

addressable

The 8051 family devices have two data memories, internal and external. With 16 address bits, there is a maximum of 64 kilobytes of external data memory, which is useful for storing large blocks of variable information that will not fit in the internal data RAM. It is enabled when the processor reads or writes data from the external data memory, signaled by activating the /RD and /WR control lines. This occurs only when a MOVX instruction is used to read or write from external memory.


36EMBEDDED CONTROLLER

Hardware Design

The internal data address space has two different parts, as shown in Figure 2-10. One part contains the general-purpose registers and general-purpose data storage RAM, and the other part contains all the special registers and I/O devices, such as the parallel and serial ports, and timers. These registers are called special function registers. There is a maximum of 256 bytes of internal RAM (128 bytes for the ’31/’51, 256 bytes for the ’32/’52) and special function registers (SFR). Four register banks (each bank has eight registers), 128 individually addressable memory bits, and the stack all reside in the internal data RAM. The stack depth is limited only by the available internal data RAM. The 8-bit stack pointer determines the stack’s location.

FF

Shared:

SFRS and

Indirect

80

@R0 OR @R1

7F

General

30

Purpose

2F

Bit

20

Addressable

1F

R7

3

18

Bank

R0

17

R7

2

Bank

10

R0

0F

R7

1

08

Bank

R0

07

R7

MOV R7

06

R6

05

R5

0

Current Bank

04

R4

Number is

Bank

RS1, RS0 Bits

03

R3

Selected by

02

R2

in PSW

01

R1

MOV R1

(PSW.R, PSW.R

00

R0

MOV R0

Figure 2-10: The internal data memory.

The internal data RAM provides a convenient 128 byte scratch pad memory which includes the register banks, SFRs, and general purpose data storage.

RAM locations 00-7F hex

Register banks: There are four register banks within the internal data RAM. Each register bank contains registers R7-R0.

128 addressable RAM bits: In the 8031, there are 128 addressable software flags in the internal data RAM. They are located in the 16 byte locations starting at byte address 20h and ending with byte location 2Fh of the RAM address space.

Special Function Register (SFR) locations 80-FF hex

General registers A, B, and other registers are mapped here.

Parallel I/O ports: The 8031 has four 8-bit ports.