Tải bản đầy đủ (.pdf) (193 trang)

Giáo trình hệ thống nhúng

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (4.8 MB, 193 trang )


h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 1
Chapter 1
Microprocessor Operation



This chapter lets you understand that the microprocessor is built of a
CPU, memory and data input/output ICs, that it operates on a "stored program"
basis, and that it is available in multi-chip/single-chip architectures.

These concepts are not confined to the H8/300H but extend to all other
kinds of microprocessors.





1.1 Microprocessor Configuration

The microprocessor is said to be a "computer built around ICs."
Mainframes, minis, and microprocessors all share the same principles of
operation and vary only in their scale, speed and architecture. The minimum
components required to build a computer are the CPU, memory and I/O
devices as shown in Figure 1.1.



Figure 1.1 Microprocessor configuration

All these components of a microprocessor are fabricated of a single IC.


Such ICs are coupled to build a computer. Three minimum ICs needed to make
up a microprocessor are the CPU, memory, and peripheral IC.


h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 2
CPU (Central Processing Unit)
The CPU forms the nucleus of any computer by executing instructions.
Microprocessors are grouped into 4-bit, 8-bit, 16-bit, and 32-bit
microprocessors according to the length of bits they can handle at a time. A 4-
bit microprocessor can handle four binary digits in a single instance of
calculation, but as many as eight digits in two instances and 16 in four
instances.
The microprocessor is also known as a "MPU (microprocessing unit)",
"microprocessor", or simply "processor."

Memory (Memory)
A device on which instructions and data are stored. Without memory,
programs and data cannot be used. In a microprocessor, ROM (read-only
memory) and RAM (random access memory) are used.

Input device (Input)
A data input device. The keyboard and mouse of a PC, for example, are
data input devices. With a built-in controller, switches and sensors are input
devices.
These input devices cannot be directly connected to a CPU, but they
must be attached to the CPU by way of a "peripheral IC," containing
connection circuitry. Depending on the kind of input device to be connected to
the CPU, an appropriate peripheral IC is used.

Output device (Output)

A data output device. The display and printer of a PC, for example, are
data output devices. With a built-in controller, display LEDs, motors, heaters
and so on are output devices. Like input devices, output devices are attached to
a CPU by way of a "peripheral IC." Depending on the kind of output device to
be connected to the CPU, an appropriate peripheral IC is used.
Input devices and output devices are collectively called "peripherals."


1.2 Stored Program Computers

The stored program computer provides a most precise concept of the
operating principles of a computer. It might be safely said that "All modern
computers are stored program computers." The stored program computer was
first conceptualized in 1947 by John von Neumann and is also known as a
"Neumann computer."
In the stored program computer, the CPU reads instructions stored in
memory in sequence, decodes and executes them.
The act of the CPU reading an instruction from memory is called
"fetch." Interpreting the fetched instruction to see what operation it defines is
called "decode." The CPU then proceeds to perform, or "execute," the
operation defined by the instruction. When the CPU has finished executing the

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 3
instruction, it fetches the next instruction. After all, the CPU infinitely repeats
the following cycle of operations:
- Instruction fetch
- Instruction decoding
- Instruction execution
Any microprocessor has a program counter in its CPU. The program
counter always holds the "address of the next instruction to be executed."

When the CPU reads an instruction, the program is automatically updated to
indicate the address of the next instruction in sequence. The program counter
thus ensures that instructions stored in memory will be executed in correct
sequence.


Figure 1.2 Operating principles of a stored program computer

1.3 Memory

Memory devices are broadly classified into two categories: ROM (read-
only memory) and RAM (random access memory).
You can only read stored data from ROM but cannot write to it. Stored
data is preserved intact, however, when the microprocessor is switched off. Use
ROM to store valuable data that needs to be protected from erasure in times of
power failures, typically, programs. Instructions are stored in ROM. Each
meaningful collection of instructions is a program. Any microprocessor would
be inoperable unless it comes up with "programs available for ready use" when
switched on. ROM fills this need.
Data can be written to and read from RAM as desired. Stored data
would be lost, however, once the microprocessor is switched off. Even when

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 4
the microprocessor is switched on again, previous data is no longer left. Hence,
RAM is used as temporary data storage. Programs may also be placed in RAM,
but will be lost once the microprocessor is switched off. To run programs in
RAM, it is necessary to attach an external storage device, such as a floppy disk
or hard disk drive, and transfer the programs to RAM from external storage to
RAM when the microprocessor is switched on.


Mask ROM (Mask ROM)
When a memory IC is manufactured in the factory, programs are
written to it. A mask is a plate of glass imprinted with patterns of wirings and
transistors used in the IC manufacturing process. Users have a semiconductor
manufacture custom-build a mask to manufacture a memory IC.
Advantages

- Suitable for volume production
- Low cost
Disadvantages

- Long lead-time from ordering to completion
- Not reprogrammable once built

EPROM (Erasable & Programmable ROM)
Stored data can be erased by ultraviolet irradiation. To this end, a
special package with a glass window is used. An EPROM writer is used to
write to EPROM. EPROM is erasable and programmable about 100 times.
Advantage

- Erasable and programmable and thus convenient for testing and debugging
Disadvantage

- Expensive because of the use of a special package

OTPROM (One Time Programmable ROM)
An EPROM chip housed in an inexpensive plastic package. Stored data
cannot be erased by ultraviolet irradiation because no glass window can be
attached to the plastic package. OPTROM can be written only once, but it
comes by far cheaper than EPROM. Programs are debugged in EPPROM and,

when finalized, moved to OTPROM for volume production.
Advantage

- Cheaper than EPROM and suitable for small-batch production
Disadvantage

- Not erasable and programmable

EEPROM (Electrically Erasable & Programmable ROM)
EEPROM can be electrically erased and programmable, and can be
reprogrammed when mounted on a board as a finished product. EEPROM is
reprogrammable about tens of thousand times.

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 5
Advantages
- Onboard reprogrammable
- Ready for infinite times of reprogramming
Disadvantage

- Expensive

Flash memory (Flash Memory)
A variation of flash memory, which is cheaper and larger-sized.
Advantage
- Cheaper and larger-sized than EEPROM
Disadvantages

- Unable to write address by address, unlike EEPROM
- Memory IC divided into blocks for erasure and reprogramming block by
block


Static RAM (Static RAM)
RAM with its storage circuit built of flip-flops. Given a supply voltage,
static RAM preserves stored data intact. It dissipates least power when out of
use. Because six transistors are used to build its flip-flops, static RAM offers
less storage capacity than does ROM.
Advantages
- Fast
- Low power consumption and suitable for battery backup
Disadvantages

- Expensive
- Small storage capacity

Dynamic RAM (Dynamic RAM)
Simplified storage circuitry with only one capacitor and one transistor
to provide each bit of memory, and hence larger-sized than static RAM.
Charges on the capacitors, however, drain with time, resulting ultimately in
loss of stored data. Before such loss, all stored data must be read out and
refreshed. Power alone does not allow dynamic RAM to retain stored data but
requires refreshing for that purpose.
Advantage
- Cheap and large-sized
Disadvantage

- Refreshing required

Table 1.1 summarizes features of key ROM and RAM devices.




h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 6
Table 1.1 Kinds and features of memory devices
Kind Features
ROM
Mask ROM
Large-sized, cheap, volume production use, custom
fabrication, not reprogrammable
EPROM
Programmable and erasable by ultraviolet
irradiation. Testing, debugging
OTPROM
Low-volume production use, one-time
programmable
EEPROM
Electrically programmable, onboard
reprogrammable
Flash memory
Electrically erasable and programmable, cheaper
and larger sized than EEPROM
RAM
Static RAM
Stored data preserved under voltage input alone,
fast, battery backup use
Dynamic RAM
Refreshing required to preserve data, large-sized,
cheap


1.4 Single-Chip/Multi-Chip Microprocessors


Putting a CPU, ROM, RAM, and data input/output circuitry into a
single IC will make a single-chip microprocessor. Single-chip microprocessors
come compact and cheap, but do not allow users to choose built-in functions at
their option. Single-chip microprocessors are also known as "microcomputer
units (MCUs)," because they are made of a single IC.
On the other hand, a computer fabricated from a mix of a CPU, memory and
data input/output devices is called a "multi-chip microprocessor." Multi-chip
microprocessors offer users greater freedom in their component choice. Multi-
chip microprocessors will prove more advantageous for larger systems
involving complexities of input/output. See how a single-chip microprocessor
and a multi-chip microprocessor differ in Figure 1.3.


h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 7

Figure 1.3 Single-chip microprocessor and multi-chip microprocessor

Single-chip microprocessors are used as built-in controllers. When a
single-chip microprocessor is switched on, the control program stored in its
internal ROM launches instantly. Internal RAM is used as temporary storage.
The internal data input/output circuits, too, have been chosen to support the
single-chip microprocessor as s controller.

Kinds of internal ROM
Early single-chip microprocessors included only mask ROM and were
available only for use in mass-produced products.
Subsequently EPROM has made inroads into single-chip
microprocessors as internal ROM. As testing and debugging was carried out in
erasable and programmable packages with windows and inexpensive plastic-

packaged OTPROM used on commercialization, single-chip microprocessors
came to be used in products manufactured in small batches as well.
Now, single-chip microprocessors with internal EEPROM and flash
memory are available for use in various applications. As the IC manufacturing
technology has been advancing from year to year, with continuing increases in
the sizes of internal ROM and RAM, state-of-the-art data input/output
functions have been used in single-chip microprocessors in an expanding of
applications.

Microprocessors and memory
A memory device organized into 8 bits per address is used. Each
sequence of 8 bits is called a "byte," and memory sizes are stated in the unit
byte.
64K bytes of memory could be connected to classical 8-bit
microprocessors as standard. This memory size indicates 8 bits per address in a
memory space of 64K (65536 addresses). Eight bits of memory per address are

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 8
also connected to 16- and 32-bit microprocessors, as well as 8-bit
microprocessors.



1. What are the three key ICs needed to make up a microprocessor?
(CPU (MPU ) )
(Memory )
(Peripheral IC)
Mainframes and minis share the same computer architecture.
Microprocessors are characterized by the fact that three components of the
computer - namely, the CPU, memory, and input/output circuit (peripheral IC)

- are each fabricated as an IC.

2. Fill the blanks with appropriate words or phrases.
The (stored program computer) provides a most precise concept of the
operating principles of a computer. This was first conceptualized in 1947 by
(John von Neumann).
The stored program computer materializes the principles of a computer
in which the CPU reads instructions from memory and executes them. This is
also known as a "Neumann computer," because of its conceptualization by
John von Neumann.

3. Mention one advantage and one disadvantage for each of the following
kinds of memory:

Mask ROM Advantage (Inexpensive, large-sized )
Disadvantage (Available only on order, not reprogrammable)

EPROM Advantage (Erasable and programmable)
Disadvantage (Expensive )

Dynamic RAM
Advantage (Inexpensive, large-sized )
Disadvantage (Refreshing required )

Mask ROM is volume-produced at factory at low cost, and features
circuit simplicity, offering large-sized memory. Mask ROM can be
manufactured only by order and is not reprogrammable after it is built.
EPROM allows about 100 times of erasure and reprogramming using a
special writer, but the special package with a glass window adds to its cost.
Using capacitors as storage devices, DRAM is simple in circuitry,

inexpensive, and large-sized, but what is inconvenient, it must be refreshed so
that charges on the capacitors do not drain.



h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 9
4. Mention one advantage and one disadvantage for the microprocessor.
Advantage (Compact, inexpensive )

Disadvantage (Limited internal functionality )
(Small memory size Not suitable for use in larger systems )
A single-chip microprocessor has all functions assembled on a single
chip and therefore comes compact and more inexpensive than purchasing its
components separately. Its scale of integration is limited and is not suitable for
mounting extra-large-sized memory.







































h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 10
Chapter 2
Knowledge of Binary Numbers Prerequisite to Writing
a Program




There are close links between the computer and binary numbers. This
chapter covers the minimum knowledge of binary numbers prerequisite to
writing a program in an assembler language. The concept of binary numbers is
not restricted to the H8/300H but broadly pertains to computers in general.
Without a correct understanding of the topics covered here, you would not be
able to write correct programs. The key concepts of "Signed binary numbers,"
"Carry," and "Overflow," among other things, would be needed instantly.
Even when you have finished with this chapter, refer back to it from
time to time as needed.





The reason why binary numbers are used in the computer is that the
computer is built of digital circuitry. Digital circuitry concerns only two states -
whether a voltage of interest is higher or lower than a given voltage - and not
any intermediate voltage. A higher-voltage state is designated by H, a lower-
voltage state by L. As the computer is a calculator, the two states of H and L
can be more conveniently expressed in numeric terms as 1 and 0 in binary. All
binary numbers that the computer handles correspond to H and L in digital
circuitry.
The unit bit, or binary digit, is used to count binary numbers. For
example, a reference to 8 bits means 8 digits in binary. A sequence of 8 bits is
called a "byte."

2.1 Kinds of Data Handled by Microprocessors

Before starting to consider how data is represented in binary numbers,
let's see what kinds of data are available. Here, data is broadly grouped into

numeric data and character data as shown in Figure 2.1.


Figure 2.1 Kinds of data

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 11
Numeric data is classified into unsigned binary numbers, signed binary
numbers that distinguish between positive and negative, and BCD code used to
express decimal numbers.
Character data is used to print or display characters, or enter characters
from the keyboard. The ASCII code is mainly used in microprocessors.

2.2 Numeric Representation in Unsigned Binary Number

Unsigned binary numbers do not allow for the positive or negative
signs. To promote understanding, unsigned binary number may be
conceptually converted to decimal numbers to express values. Consider an
eight-digit binary number as an example.
Since each digit of a binary number has a weight of 2, the least
significant digit is 2
0
, or 1, the next digit is 2
1
, or 2, and still the next digit is 2
2
,
or 4. Thus, the weight doubles on each carry. In converting an 8-bit binary
number to a decimal number, assuming



we get
Decimal representation =
a
7
*2
7
+ a
6
*2
6
+ a
5
*2
5
+ a
4
*2
4
+ a
3
*2
3
+ a
2
*2
2
+ a
1
*2
1

+ a
0
*2
0


10110010 in binary, for example, is converted to a decimal equivalent as
1*2
7
+ 0*2
6
+ 1*2
5
+ 1*2
4
+ 0*2
3
+ 0*2
2
+ 1*2
1
+ 0*2
0

= 128 + 32 + 16 + 2
= 178
All-one data "11111111" is the largest number that can be expressed in
an 8-bit format. It corresponds to 255 in decimal. Eight-bit unsigned binary
numbers can represent decimal numbers from 0 to 255.
Generally, N-bit unsigned binary numbers can represent the range of 0

to 2
N
-1

Table 2.1 lists the lengths of unsigned binary numbers and the ranges
they can represent.

Table 2.1 Ranges of unsigned binary numbers
Binary number length Range that can be represented
4 digits (4 bits)
0 to 15
8 digits (8 bits)
0 to 255
16 digits (16 bits)
0 to 65,535
32 digits (32 bits)
0 to 4,294,967,295




h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 12
Examples of addition of unsigned binary numbers are given below. To
their right are their decimal equivalents.

10000010
00111000
01001010
+


130
56
74
+

and,

00000011
01111010
10001001
1
+

3
122
173
+


This calculation, on the other hand, yields an incorrect result. The
resultant 9-bit value of 255 may appear correct, but the fact is that "calculating
in 8-bit terms within the computer delivers a result in 8-bit terms only." You
can stretch or contract the length of a value as long as you work on its
calculation on paper or in your brains, but not in the computer. You need to
remember the length of arithmetic circuitry in the computer at all times.
The addition of an extra digit to the length of a result is called a "carry."


Figure 2.2 Carry in a binary number


Next, examples of subtraction of unsigned binary numbers are given
below. To their right are their decimal equivalents.
00011110
10010111
10110101


30
151
181


and,

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 13

11111111
01010000
01001111


255
80
79



This calculation yields an incorrect result due to its failure to subtract a
given value from a smaller value, where a 1 was leased from the ninth bit of
the lower value. This is called a "borrow."


When a carry or borrow occurs in the course of a calculation in the
computer, they are stored in status (in the H8/300H, the condition code). When
writing a program, include a condition test instruction to define what specific
action should be taken if a carry or borrow is encountered in the execution of a
calculation instruction.
Generally, no distinction is made between a carry and a borrow in the
computer, but they are collectively called a "carry."

2.3 Numeric Representation in Signed Binary Number

Signed binary numbers distinguish between positive and negative, but
they cannot be prefixed with a sign, as in +10110001 or -11001110. This is
because the computer operates on the basis of digital circuitry in which only
two voltage states H and L exist, as explained earlier. As H and L are
designated by 1 and 0, the positive and negative states must be designated by a
combination of 1 and 0, as well.
To promote understanding, the most significant bit of data is assumed
to designate a sign. Eight-bit data is expressed as
-(a
7
*2
7
)+ a
6
*2
6
+ a
5
*2

5
+ a
4
*2
4
+ a
3
*2
3
+ a
2
*2
2
+ a
1
*2
1
+ a
0
*2
0


Only the most significant bit is treated as being negative. Accordingly,

00000000 represents +0
00000001 represents +1
00000010 represents +2
--------
01111111 represents +127


Thus, signed binary values having their most significant bit being 0 are treated
positive.

10000000 represents -128
10000001 represents -127
10000010 represents -126
--------
11111111 represents -1


h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 14
Thus, signed binary values having their most significant bit being 1 are treated
negative.
Generally, N-bit signed binary numbers can represent values in the following
range:
-2
N-1
to +2
N-1
-1

Table 2.2 lists the lengths of signed binary numbers and the ranges they
can represent.

Table 2.2 Ranges of signed binary numbers
Binary number length Range that can be represented
4 digits (4 bits) -8 to -1, +0 to +7
8 digits (8 bits) -128 to -1, +0 to 127
16 digits (16 bits) -32,768 to -1, +0 to 32,767


The most significant bit of a signed binary number is called a "sign bit"
because it denotes a sign.


Figure 2.3 8-bit binary numbers

Examples of addition of signed binary numbers are given below.

00000000
11111111
00000001
1
+

0
1
1
+

+
+






h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 15
The result is correct if only the low-order 8 digits are considered.


01100000
00100000
10000000
1


96 +
32 +
128-



This calculation, on the other hand, gives an incorrect result, because
the correct result of +144 cannot be represented by an 8-bit signed binary
number. Such a state of a result exceeding a predetermined length is called an
"overflow."

Next, examples of subtraction of signed binary numbers are given below.

11111111
01010010
01010001


1-
82+
81+



No overflow has occurred in this calculation.
00100000
00100000
10000000


96+
32+
128-


Subtracting a positive value from a negative value should always
deliver a negative value, but an overflow is seen in this case because the result
is positive. Summing up, the following four conditions
Positive value + Positive value = Negative value
Negative value + Negative value = Positive value
Positive value - Negative value = Negative value
Negative value - Positive value = Positive value
are called "overflows."
It is important to note the length of any signed binary number, because
simply prefixing a signed binary number with 0 could result in an inverted sign
as in the following example:
8-bit 1000 0010 is -126
9-bit 0 1000 0010 is +130


Twos complement notation
Signed binary numbers are also called a "twos complement notation." If
summing up two values produces a carry, with the result of 0, then a twos
complement relation exists between the two values as in the following

example:
00000000
01001111
10110001
1
+

These two values have the same absolute value but differ only in their
sign. Ones complements, too, exist.

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 16

11111111
01001110
10110001
+

If summing up two values results in a complete sequence of 1s, a ones
complement relation is said to exist between them. These two values have their
0s and 1s inverted.
Changing the sign of a signed binary number can be easily done by
creating its ones complement and then adding 1 to it. This is the same as
calculating a complement. As an example, consider converting +12 to -12. +12
can be expressed in an 8-bit format as:
00001100
First, create the ones complement of 00001100:
11110011
Then, add 1 to it to get:
11110100, or -12


2.4 BCD Code


Short for "Binary Coded Decimal," BCD code means a decimal number
expressed in binary. The BCD code represents each decimal digit with a string
of four binary digits. For example, decimal 156 is expressed as 0001 0101
0110 in BCD code.
The addition of BCD coded characters must deliver a decimal result
like 48 + 24 = 72 as in the example:

01110010
00100100
01001000
+

72
24
48
+

It involves addition different from the ordinary addition of binary numbers. To
this end, special instructions are needed to perform BCD calculations.

2.5 ASCII Code

The ASCII (American Standard Code for Information Interchange)
code is used to represent alphanumeric characters and symbols. The ASCII
code represents each character with 8 bits. Table 2.3 is an ASCII code table.
For example, A is represented by 01000001 and a by 01100001.
When you type 123 from the keyboard and then press the return key,

the following four characters are entered:

Character code of 1 00110001
Character code of 2 00110010
Character code of 3 00110011
Character code of the return 00001101


h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 17
To handle these characters as unsigned binary 123, they must be
converted to the binary number:
01111011
On the other hand, to display signed binary number
10000000
on the display as -128, it must be converted to the four characters:
Character of the minus sign 00101101
Character code of 1 00110001
Character code of 2 00110010
Character code of 8 0011100

Note that the ASCII code is characters, and 1 through 9 are "digits" and
not "numeric values."

[Audiovisual guidance]


2.6 Numeric Representations

While the computer internally operates on the basis of binary numbers,
binary numbers take more digits than decimal numbers to represent the same

value. For example, decimal 100 can be expressed in three digits, but its
unsigned binary equivalent would end up in a seven-digit sequence of
1100100. Hexadecimal numbers save on extra lengths and make values easier
to read. Memory addresses are expressed in hexadecimal in most situations.
Binary notation also comes an effective way of representation as long
as economizing on lengths is concerned, but it involves a laborious binary
conversion process. Hexadecimal numbers are easy to convert to and from

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 18
binary numbers, because each hexadecimal digit simply represents a string of
four binary digits.
Table 2.4 gives the correspondence among binary, hexadecimal, and
decimal numbers.

Table 2.4 Correspondence among binary, hexadecimal and decimal
numbers
Binary Hexadecimal Decimal
0000
0 0
0001
1 1
0010
2 2
0011
3 3
0100
4 4
0101
5 5
0110

6 6
0111
7 7
1000
8 8
1001
9 9
1010
A 10
1011
B 11
1100
C 12
1101
D 13
1110
E 14
1111
F 15

In programs, H 'and B' designate hexadecimal notation and binary
notation, respectively. For example, binary 12 is written as H'12, and binary
01011110 is expressed as B'01011110. 12 or 10, when simply stated, means a
decimal number.

Example:
H'12 H' identifies a hexadecimal number. It is 18 in decimal and
00010010 in binary.
B'01011100 B' identifies a binary number. It is 5C in hexadecimal and 92 in
decimal.

110 Decimal number. It is 6E in hexadecimal and 01101110 in
binary.









h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 19


1. Fill out the blanks below.

Binary notation
(8 bits)
Decimal notation
(unsigned)
Decimal
notation (signed)
Hexadecimal
notation
01001110 78 78 H'4E
01100100
100
100 H'64
11111101 253
-3

H'FD
10000000 128 -128
H'80

Binary notation 01001110
Decimal notation (signed) 01001110 = 64 + 8 + 4 = 2 = 78
Decimal notation (signed) = positive + 78, because the most significant bit is 0
Hexadecimal notation 0100 = 4 and 1110 = E, hence H'4E

Decimal notation (unsigned) 100
Binary notation 100 = 64 + 32 + 4 = 01100100
Decimal notation (signed) = positive + 100, because the most significant bit is 0
Hexadecimal notation 0110 = 6 and 0100 = 4, hence H'64

Decimal notation (signed) -3
Binary notation -3 = -128 + 64 + 32 + 16+ 8 + 4 + 1 = 11111101
Decimal notation (unsigned) 128 + 64 + 32 + 16+ 8 + 4 + 1 = 253
Hexadecimal notation 1111 = F and 1101 = D, hence H'FD

Hexadecimal notation H'80
Binary notation 10000000 = -128
Decimal notation (unsigned) 10000000 = 128
Decimal notation (signed) = negative -128, because the most significant bit is 1

2. Perform the operations given below and calculate the results to a length
of 8 bits. Answer also whether a carry or borrow has been produced from
the operations and whether an overflow has occurred from the results
when they are viewed as signed binary numbers.

Carry (

Yes
)
Overflow (
No
)

The result is 9 digits, with a carry.
+72 + (-49) = +23, or positive + negative = positive with no overflow

Borrow (
No
)
Overflow (
Yes
)

No borrow and no carry.
-116 - (+43) = +65, or negative - positive = positive, with an overflow

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 20
Chapter 3
H8/300H Series Overview, and H8/3048



This chapter describes the use of an H8/3048 microcomputer from the
H8/300H family. The H8/3048 is a high-performance microcomputer having
ROM, RAM and peripheral functions.
It will help you understand the functions of this product.






3.1 H8/300H Series Product Map

The H8/300H series is a original high-performance, single-chip
microcomputer having a 16-bit CPU as its core together with peripheral
functions required for system configuration. Figure 3.1 shows the product
lineup of the H8 family.


Figure 3.1: Product Lineup of H8 Family


Figure 3.2 shows the product lineup of the H8/300H series.

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 21

Figure 3.2: Product Lineup of H8/300H series

3.2 H8/3048 Overview

In this course, an H8/3048 is used as the sample processor from the
H8/300H family. The H8/3048 includes the following three types: one having a
mask ROM or OTPROM as an internal ROM (simply referred to as the
H8/3048), an H8/3048F having an internal writable flash memory with two
power supplies (5V and 12V) and an H8/3048F-ONE having an internal
writable flash memory with a single power supply (5V). The only difference
among them is the type of internal ROM, the rest are almost the same.

Although this chapter describes the overview of the H8/3048F-ONE, the
descriptions in this and following chapters are common to all types. Note,
however, that the training board has been developed based on the H8/3048F-
ONE.
Figure 3.3 shows the H8/3048F-ONE internal block.


h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 22

Figure 3.3: H8/3048F-ONE Internal Block

Features of CPU
- 16-bit CPU which serves as a general-purpose register machine.
Equipped with 16-bit × 16 general-purpose registers.
(Also available in 8-bit × 16 + 16-bit × 8 or 32-bit × 8 form.)

- High-speed CPU.
The maximum operating frequency of the H8/3048F-ONE is
25MHz and addition/subtraction can be executed in 80ns and
multiplication/division in 560ns.
The CPU is operated based on clock signals and the higher the
clock signal frequency, the faster the operation. The time of one
25MHz clock signal pulse is 0.04 microsecond (40ns), which is called
"1 state". Addition/subtraction are completed in two states and
multiplication/division in 14 states.

- Equipped with a maximum 16M bytes of address space.
(CPU, instructions and programs are described in Chapters 4, 5 and 6.)

Available both as single-chip and multi-chip microcomputer


It can be used as a single-chip microcomputer thanks to the internal
ROM, RAM and data I/O functions in addition to the CPU.
It can also be used as a multi-chip microcomputer when an external
memory is added due to insufficient ROM or RAM capacity. When used as a
multi-chip microcomputer, it has 24 address pins and up to 16M bytes of
memory can be added. Addresses consume 16M, 8 bits per address. Since there
are 16 data pins, 16 bits can be read or written simultaneously.



h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 23
Internal ROM

It has a 128k byte, writable flash memory with a single 5V power
supply. This enables onboard writing.
For writing to the flash memory, a boot mode using a serial interface is
supported. Writing with a user-defined program is also available.

Internal RAM

It has an internal, 4k byte RAM.

I/O ports: 70 I/O pins and 8 input-only pins

The I/O ports can be used to input switch on/off statuses or signals from
various sensors. When used as output ports, they can control blinking of a
display lamp or turn a motor or heater on and off. The I/O ports are widely
used as general-purpose I/O functions.
On the training board, they are used to read switch statuses and control

LED displays.

Internal SCI (serial communication interface) × 2 channels

Channel 0 is available for a smart card interface.
For start-stop synchronization, it is used for RS-232C and other
communication functions. It is connected to a PC to enable data exchange.
On the training board, it is connected to a PC via RS-232C to send a
created program from a PC to the board or input a command for debugging.

Internal ITU (integrated timer unit) composed of 16-bit timer × 5 channels

Pulse outputs from up to 12 pins and up to 10 types of pulse inputs can
be processed.
It has a wide variety of uses such as measurement of time, speed and
frequency as well as control of pulse motors.
On the training board, a piezoelectric buzzer is provided so that pulses
can be heard as sounds.

Internal TPC (programmable timing pattern controller)
capable of outputting up to 16-bit pulses using the ITU as a time base

In combination with the ITU, a large number of pulse outputs are
available.

Internal watch-dog timer

Program runaway can be detected. Since control using a microcomputer
is based on programs, an extremely dangerous situation may occur if a program
should run away. This function is indispensable for creating a highly reliable

system.

Internal A/D converter with 10-bit resolution × 8 channels

The A/D converter is designed to input analog voltages instead of
digital voltages. For example, signals from a temperature sensor are input not

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 24
by high/low digital voltages but analog voltages. These signals are read after
being converted into 10-bit binary numbers.
On the training board, 0 to 5V analog voltages can be input with added
volume.

Internal 8-bit D/A converter × 2 channels

Unlike the A/D converter, the D/A converter is designed to output
analog voltages. It is also used to output desired waveforms or adjust volume
or hue of a TV.
On the training board, LEDs can be driven with D/A-converted output
voltages to control brightness.

Internal DMA controller × 4 channels (max.)

Used for high-speed data transfer. It enables data to be transferred faster
than with the CPU. It is generally used with a timer and other communication
functions.

Internal refresh controller

Refreshing is required to retain the data in the dynamic RAM. This

microprocessor has an internal controller for this purpose.

The H8/3048F-ONE can be used as a single-chip microcomputer. In
this form, no external memory can be added and only the internal one is
available. The operating mode when it is used as a single-chip microcomputer
is referred to as "single-chip mode". Figure 3.4 shows the memory map in
single-chip mode. In this mode, the memory addresses are expressed with 20
bits (5 digits in hexadecimal notation).



Figure 3.4: Memory Map in Single-chip Mode

h t t p : / / r e s o u r c e . r e n e s a s . c o m Page 25

For the vector area, refer to "Exception Handling".

For the memory indirect branch addresses, refer to
"Addressing Modes
of Instructions".


The internal I/O registers are used for peripheral functions such as the
SCI and timer.

Memory indirect
Addressing for branching by storing the destination address in the
memory and specifying it.
This is written in the following format:
@@ address

Memory indirect is available only for the JSR and JMP instructions. An
even-numbered address between H’000000 and H’0000FC can be specified for
an instruction. Not all addresses can be used freely, however, since other
exception handling functions also use the same range.

Sample: JMP @@H'10
Branches to the address stored in the H'10 address.

Although the destination is written with 32 bits in the memory, only the
lower 24 bits are used. An even address must be specified by an instruction.
The address of the memory storing the destination can also be specified using a
symbol. The assembler converts a written symbol into an address, which is
assumed to be the destination.

Sample: JMP @@WORK
Branches to the address written in the WORK address.

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×