Keep safety first in your circuit designs!
1 . Renesas Technology Corporation puts the maximum effort into making semiconductor products better and more reliable, but
there is always the possibility that trouble may occur with them. Trouble with semiconductors may lead to personal injury, fire or
property damage.
Remember to give due consideration to safety when making your circuit designs, with appropriate measures such as (i) placement
of substitutive, auxiliary circuits, (ii) use of nonflammable material or (iii) prevention against any malfunction or mishap.
Notes regarding these materials
1 . These materials are intended as a reference to assist our customers in the selection of the Renesas Technology Corporation
product best suited to the customer's application; they do not convey any license under any intellectual property rights, or any
other rights, belonging to Renesas Technology Corporation or a third party.
2 . Renesas Technology Corporation assumes no responsibility for any damage, or infringement of any third-party's rights,
originating in the use of any product data, diagrams, charts, programs, algorithms, or circuit application examples contained in
these materials.
3 . All information contained in these materials, including product data, diagrams, charts, programs and algorithms represents
information on products at the time of publication of these materials, and are subject to change by Renesas Technology
Corporation without notice due to product improvements or other reasons. It is therefore recommended that customers contact
Renesas Technology Corporation or an authorized Renesas Technology Corporation product distributor for the latest product
information before purchasing a product listed herein.
The information described here may contain technical inaccuracies or typographical errors.
Renesas Technology Corporation assumes no responsibility for any damage, liability, or other loss rising from these inaccuracies
or errors.
Please also pay attention to information published by Renesas Technology Corporation by various means, including the
Renesas Technology Corporation Semiconductor home page (http://www.renesas.com).
4 . When using any or all of the information contained in these materials, including product data, diagrams, charts, programs, and
algorithms, please be sure to evaluate all information as a total system before making a final decision on the applicability of the
information and products. Renesas Technology Corporation assumes no responsibility for any damage, liability or other loss
resulting from the information contained herein.
5 . Renesas Technology Corporation semiconductors are not designed or manufactured for use in a device or system that is used
under circumstances in which human life is potentially at stake. Please contact Renesas Technology Corporation or an
authorized Renesas Technology Corporation product distributor when considering the use of a product contained herein for any
specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater
use.
6 . The prior written approval of Renesas Technology Corporation is necessary to reprint or reproduce in whole or in part these
materials.
7 . If these products or technologies are subject to the Japanese export control restrictions, they must be exported under a license
from the Japanese government and cannot be imported into a country other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the country of destination is
prohibited.
8 . Please contact Renesas Technology Corporation for further details on these materials or the products contained therein.
Preface
The SH7040 Series (SH7040, SH7041, SH7042, SH7043, SH7044, SH7045) single-chip RISC
(Reduced Instruction Set Computer) microprocessors integrate a Renesas Technology-original
RISC CPU core with peripheral functions required for system configuration.
The CPU has a RISC-type instruction set. Most instructions can be executed in one clock cycle,
which greatly improves instruction execution speed. In addition, the 32-bit internal-bus
architecture enhances data processing power. With this CPU, it has become possible to assemble
low cost, high performance/high-functioning systems, even for applications that were previously
impossible with microprocessors, such as real-time control, which demands high speeds. In
particular, the SH7040 series has a 1-kbyte on-chip cache, which allows an improvement in CPU
performance during external memory access.
In addition, the SH7040 series includes on-chip peripheral functions necessary for system
configuration, such as large-capacity ROM and RAM, timers, a serial communication interface
(SCI), an A/D converter, an interrupt controller, and I/O ports. Memory or peripheral LSIs can be
connected efficiently with an external memory access support function. This greatly reduces
system cost.
There are versions of on-chip ROM: mask ROM, PROM, and flash memory. The flash memory
can be programmed with a programmer that supports SH7040 series programming, and can also
be programmed and erased by software.
This hardware manual describes the SH7040 series hardware. Refer to the programming manual
for a detailed description of the instruction set.
Related Manual
SH7040 series instructions
SH-1/SH-2/SH-DSP Programming Manual
Please consult your Renesas Technology sales representative for details for development
environment system.
List of Items Revised or Added for This Version
SectionPageDescription
1.1.1 SH7040 Series
Features
Notes on the
SH7040 Series
Specifications
7,
9
Type AbbreviationPackageFrequency Voltage Type NameROM
ZTAT SH7042128 kB 16 bits ±15LSB
FLASH SH7044F256 kB 16 bits ±4LSB
MASK SH7040A64 kB 16 bits ±4LSB
ROM
less
Note: Package with Copper used as the lead material.
Mask
Version
SH7042A A mask
SH7043128 kB 32 bits ±15LSB
SH7043A A mask 128 kB 32 bits ±4LSB
A mask
SH7045F A mask 256 kB 32 bits ±4LSB
A mask
SH7041A A mask 64 kB 32 bits ±4LSB
SH7042128 kB 16 bits ±15LSB
SH7042A A mask 128 kB 16 bits ±4LSB
SH7043128 kB 32 bits ±15LSB
SH7043A A mask 128 kB 32 bits ±4LSB
SH7044 A mask 256 kB 16 bits ±4LSB
SH7045 A mask 256 kB 32bits ±4LSB
A mask
SH7040A16 bits ±4LSB
SH7041A A mask32 bits ±4LSB
A/D
External
Bus Width
Accuracy
(5Vversion)
(High-Speed)
(Mid-Speed)
(High-Speed)
(Mid-Speed)
(Mid-Speed)
(Mid-Speed)
(Mid-Speed)
(Mid-Speed)
(High-Speed)
(Mid-Speed)
(High-Speed)
(Mid-Speed)
(Mid-Speed)
(Mid-Speed)
(Mid-Speed)
(Mid-Speed)
On-chip
ROM
128 kB 16 bits ±4LSB
Operating
Temp
QFP2020-112 –20°C to 75°C 28 MHz
–20°C to 75°C 28 MHz
QFP2020-112
TQFP1414-120
QFP2020-112Cu*
QFP2020-144 –20°C to 75°C 28 MHz
QFP2020-144
–20°C to 75°C 28 MHz
QFP2020-144Cu*
QFP2020-112 –20°C to 75°C 28 MHz 5 V HD64F7044F28See “256 kB Flash
QFP2020-144 –20°C to 75°C 28 MHz 5 V HD64F7045F28See “256 kB Flash
–20°C to 75°C 28 MHz
QFP2020-112
TQFP1414-120
QFP2020-112Cu*
QFP2020-144
–20°C to 75°C 28 MHz
QFP2020-144Cu*
QFP2020-112 –20°C to 75°C 28 MHz
QFP2020-112
–20°C to 75°C 28 MHz
TQFP1414-120
QFP2020-112Cu*
QFP2020-144 –20°C to 75°C 28 MHz
QFP2020-144
–20°C to 75°C 28 MHz
QFP2020-144Cu*
QFP2020-112 –20°C to 75°C 28 MHz 5 V HD6437044F28See “256 kB Mask
QFP2020-144 –20°C to 75°C 28 MHz 5 V HD6437045F28See “256 kB Mask
Pin and HN27C101
Pin Correspondence
(120-Pin Version)
100 Ω
0.1 µF
Figure 21.4 SH7043
Pin and HN27C101
Pin Correspondence
(144-Pin Version)
22.2.2 Mode
Transition Diagram
Figure 22.2 Flash
Memory Mode
Transitions
673Figure amended
2 nF
100 Ω
0.1 µF
683
Note amended
Execute transition between the user mode and user program mode
while the CPU is not programming or erasing the flash memory
SectionPageDescription
22.7.2 Program-
706
Figure amended
Verify Mode
Figure 22.13
Program/Program
Verify Flow
Verify
Increment address
NG
Start
Set SWE bit in FLMCR1
Wait 10 µs
Store 32-byte program data in
reprogram data area
n = 1
m = 0
Write 32-byte data in reprogram data area
in RAM to flash memory consecutively
Enable WDT
Set PSU1(2) bit in FLMCR1(2)
Wait 50 µs
Set P1(2) bit in FLMCR1(2)
Wait 200 µs
Clear P1(2) bit in FLMCR1(2)
Wait 10 µs
Clear PSU1(2) bit in FLMCR1(2)
Wait 10 µs
Disable WDT
Set PV1(2) bit in FLMCR1(2)
Wait 4 µs
Dummy write of H'FF to verify address
Wait 2 µs
Read verify data
3
Program data = verify data?
OK
Reprogram data computation
Transfer reprogram data to reprogram
data area
End of 32-byte
data verification?
OK
Clear PV1(2) bit in FLMCR1(2)
Wait 4 µs
flag = 0?
OK
Clear SWE bit in FLMCR1
*
5
*
4
*
1
*
5
*
Start of programming
5
*
End of programming
5
*
5
*
5
*
5
*
2
*
m = 1
NG
3
*
4
*
5
*
NGNG
Clear SWE bit in FLMCR1
n ≥ 1000
5
*
*5
OK
n ← n + 1
End of programming
Note *5 added.
*5 Make sure to set the wait times and repetitions as specified.
Programming may not complete correctly if values other than
the specified ones are used.
Programming failure
SectionPageDescription
22.7.4 Erase-Verify
713
Figure amended
Mode
Figure 22.14
Erase/Erase-Verify
Flowchart
Increment
address
Notes: *1 Preprogramming (setting erase block data to all “0”) is not necessary.
*2 Verify data is read in 32-bit (longword) units.
*3 Set only one bit in EBR1(2). More than one bit cannot be set.
*4 Erasing is performed in block units. To erase a number of blocks, each block must be erased in turn.
*5 Make sure to set the wait times and repetitions as specified. Erasing may not complete correctly if values other
than the specified ones are used.
*1
Start
Set SWE bit in FLMCR1
Wait 10 µs
n = 1
Set EBR1(2)
Enable WDT
Set ESU1(2) bit in FLMCR1(2)
Wait 200 µs
Set E1(2) bit in FLMCR1(2)
Wait 5 ms
Clear E1(2) bit in FLMCR1(2)
Wait 10 µs
Clear ESU1(2) bit in FLMCR1(2)
Wait 10 µs
Disable WDT
Set EV1(2) bit in FLMCR1(2)
Wait 20 µs
Set block start address to verify address
H'FF dummy write to verify address
Wait 2 µs
Read verify data
Verify data = all "1"?
NG
Clear EV1(2) bit in FLMCR1(2)
*4
NG
Clear SWE bit in FLMCR1
OK
Last address of block?
OK
Wait 5 µs
End of
erasing of all erase
blocks?
OK
End of erasing
*5
*3
*5
Start erase
*5
Halt erase
*5
*5
*5
*5
*2
NG
Clear EV1(2) bit in FLMCR1(2)
*5*5
Wait 5 µs
*5
n ≥ 60?
Clear SWE bit in FLMCR1
OK
Erase failure
n ← n + 1
NG
24.4.2 Canceling the
Standby Mode
25. Electrical
Characteristics (5V,
33.3 MHz Version)
747
—
Cancellation by a Manual Reset deleted
Deleted
SectionPageDescription
25.2 DC
Characteristics
751Note amended
*2 5 mA in the A mask version, except for F-ZTAT products.
Table 25.2 DC
Characteristics
25.3.2 Control
Signal Timing
Table 25.5 Control
Signal Timing
754Note amended
Note: * The RES, MRES, NMI, BREQ, and IRQ7–IRQ0 signals are
asynchronous inputs, but when thesetup times shown here
are provided, the signals are considered to have produced
changes at clock rise (for RES, MRES, BREQ) or clock fall
(for NMI and IRQ7–IRQ0). If the setup times are not
provided, recognition is delayed until the next clock rise or
fall.
25.3.3 Bus Timing
Figure 25.12 DRAM
763Figure amended
Tcw1Tc2
Cycle (Normal Mode,
1 Wait, TPC=0,
RCD=0)
Column address
t
CASD1
t
CAC
t
t
RAC
t
AA
RDS
Figure 25.13 DRAM
Cycle (Normal Mode,
2 Waits, TPC=1,
RCD=1)
764Figure amended
Tcw1Tcw2
Column address
t
CASD1
t
CAC
t
AA
SectionPageDescription
25.3.3 Bus Timing
Figure 25.14 DRAM
764Figure amended
Tcw1Tcw2
Cycle (Normal Mode,
3 Waits, TPC=1,
RCD=1)
t
CASD1
t
CAC
t
AA
Column
25.3.5 Multifunction
Timer Pulse Unit
Timing
Figure 25.23 MTU
I/O Timing
Figure 25.24 MTU
Clock Input Timing
25.3.11 Measuring
Conditions for AC
Characteristics
Figure 25.33 Output
Load Circuit
770Figure amended
t
TOCD
770Figure amended
t
TCKS
778
Title amended
Output Load Circuit
SectionPageDescription
25.4 A/D Converter
779
Table amended
Characteristics
Table 25.16 A/D
Converter Timing (A
mask)
Non-linearity error
Offset error
Full scale error
Quantize error
*
*
*
*
26.2 DC
Characteristics
Table 26.2 DC
Characteristics
26.3.2 Control
Signal Timing
Table 26.5 Control
Signal Timing
26.3.3 Bus Timing
Figure 26.12 DRAM
Cycle (Normal Mode,
1 Wait, TPC = 0,
RCD = 0)
782
783
786
795
Table amended
Schmitt
trigger input
voltage
PA2, PA5, PA6–
PA9,
PE0–PE15
–
+
V
VCC×
0.07
——
– V
T
T
+
V
VT
≥ VCC× 0.9V (min)
VT– ≤ VCC× 0.2V (max)
Table amended
Analog
supply
current
*3 2 mA in the A mask version of MASK products.
AI
CC
AI
ref
—48
—0.5 1
*
mA f = 16.7MHz
3
mA QFP144 version only
Note amended
Notes: *1 SH7042/43 ZTAT (excluding A mask) are 3.2V.
*2 The RES, MRES, NMI, BREQ, and IRQ7–IRQ0 signals
are asynchronous inputs, but when the setup times
shown here are provided, the signals are considered to
have produced changes at clock rise (for RES, MRES,
BREQ) or clock fall (for NMI and IRQ7–IRQ0). If the
setup times are not provided, recognition is delayed until
the next clock rise or fall.
PB0–PB9
PC0–PC15
PD0–PD31
PE0–PE8,PE10
PE9,PE11–PE15 Z
PF0–PF17ZIZIIZ
Notes: 1. There are instances where bus right release and transition to software standby mode
occur simultaneously due to the timing between BREQ and internal operations. In such
cases, standby mode results, but the standby state may be different.
The initial pin states depend on the mode. See section 18, Pin Function Controller
(PFC), for details.
2. I: Input, O: Output, H: High-level output, L: Low-level output, Z: High impedance,
K: Input pin with high impedance, output pin mode maintained.
*1 If the standby control register port high-impedance bits are set to 1, output pins become
high impedance.
*2 A21–A18 will become input ports after power-on reset.
*3 Input in the SH7044/SH7045 F-ZTAT version.
*4 General use I/O ports PAn, PBn, PCn, PDn, and PEn, as well as pins multiplexed with
them, are unstable during the RES setup time (t
goes to low level.
Pin modes
Bus RightStandby in Bus
4
*
Z
I/OK
4
*
Z
I/OZI/OI/OZ
4
*
IZIIZ
4
*
IZIIZ
4
*
I/OZI/OI/OZ
4
*
OO
4
*
IZIIZ
4
*
IZIIZ
4
*
I/OK
4
*
I/OZKI/OZ
1
*
I/OI/OK
1
*
OOO
1
*
KI/OK
) immediately after the RES pin
RESS
1
*
1
*
1
*
SectionPageDescription
Appendix C Pin
867
Table amended
States
Table C.2 Pin
Modes During Reset,
Power-Down, and
Bus Right Release
Modes (112 Pin,
120 Pin)
PF0–PF7ZIZIIZ
Notes: 1. There are instances where bus right release and transition to software standby mode
occur simultaneously due to the timing between BREQ and internal operations. In such
cases, standby mode results, but the standby state may be different.
The initial pin states depend on the mode. See section 18, Pin Function Controller
(PFC), for details.
2. I: Input, O: Output, H: High-level output, L: Low-level output, Z: High impedance,
K: Input pin with high impedance, output pin mode maintained.
*1 If the standby control register port high-impedance bits are set to 1, output pins become
high impedance.
*2A21–A18 will become input ports after power-on reset.
*3 Input in the SH7044/SH7045 F-ZTAT version.
*4 General use I/O ports PAn, PBn, PCn, PDn, and PEn, as well as pins multiplexed with
them, are unstable during the RES setup time (t
goes to low level.
Pin modes
Bus RightStandby in Bus
4
*
IZIIZ
4
*
I/OZI/OI/OZ
4
*
OO
4
*
IZIIZ
4
*
IZIIZ
4
*
I/OK
4
*
I/OZKI/OZ
1
*
OOO
1
*
KI/OK
) immediately after the RES pin
RESS
1
*
1
*
SectionPageDescription
Appendix E Product
Code Lineup
Table E.1 SH7040,
SH7041, SH7042,
876,
877
Table amended
Product
Type
SH7040A Mask ROM
verion
SH7043, SH7044,
and SH7045 Product
Lineup
ROM less
verion
SH7041A Mask ROM
verion
ROM less
verion
SH7042 Mask ROM
verion
Z-TAT
version
SH7042A Mask ROM
verion
Product
Type
SH7042A Z-TAT
version
SH7043 Mask ROM
version
Z-TAT
version
SH7043A Mask ROM
version
Z-TAT
version
SH7044 Mask ROM
version
F-ZTAT
version
SH7045 Mask ROM
version
F-ZTAT
version
(***) is the ROM code.
NoteS: 1. Package with Copper used as the lead material.2. *** in the Order Model No. is the ROM code, consisting of a letter and a two-digit
number (ex. E00). The letter indicates the voltage and frequency, as shown below.
• E, F, G, H: 5.0 V, 28 MHz
• P, Q, R: 3.3 V, 16 MHz
The SH7040 Series (SH7040/41/42/43/44/45) CMOS single-chip microprocessors integrate a
Renesas-original architecture, high-speed CPU with peripheral functions required for system
configuration.
The CPU has a RISC-type instruction set. Most instructions can be executed in one clock cycle,
which greatly improves instruction execution speed. In addition, the 32-bit internal-bus
architecture enhances data processing power. With this CPU, it has become possible to assemble
low cost, high performance/high-functioning systems, even for applications that were previously
impossible with microprocessors, such as real-time control, which demands high speeds. In
particular, the SH7040 series has a 1-kbyte on-chip cache, which allows an improvement in CPU
performance during external memory access.
In addition, the SH7040 Series includes on-chip peripheral functions necessary for system
configuration, such as large-capacity ROM and RAM, timers, a serial communication interface
(SCI), an A/D converter, an interrupt controller, and I/O ports. Memory or peripheral LSIs can be
connected efficiently with an external memory access support function. This greatly reduces
system cost.
In addition to the masked-ROM versions of the SH7040 series, the SH7042 and SH7043 have a
1
ZTAT™
F-ZTAT
*
version with user-programmable on-chip PROM and the SH7044 and SH7045 have an
TM*2
version with on-chip flash memory. These versions enable users to respond quickly
and flexibly to changing application specifications, growing production volumes, and other
conditions.
Notes: *1 ZTAT (Zero Turn-Around Time) is a registered trademark of Renesas Technology
Corp.
*2 F-ZTAT (Flexible ZTAT) is a trademark of Renesas Technology Corp.
1.1.1SH7040 Series Features
CPU:
• Original Renesas architecture
• 32-bit internal data bus
• General-register machine
Sixteen 32-bit general registers
Three 32-bit control registers
Four 32-bit system registers
• RISC-type instruction set
1
Instruction length: 16-bit fixed length for improved code efficiency
Load-store architecture (basic operations are executed between registers)
Delayed branch instructions reduce pipeline disruption during branch
Instruction set based on C language
• Instruction execution time: one instruction/cycle (35 ns/instruction at 28.7-MHz operation)
multiplication/accumulation operations (32 bits × 32 bits + 64 bits → 64 bits) executed in two
to four cycles
• Five-stage pipeline
Cache Memory:
• 1-kbyte instruction cache
• Caching of instruction codes and PC relative read data
• 4-byte line length (1 longword: 2 instruction lengths)
• 256 entry cache tags
• Direct map method
• On-chip ROM/RAM, and on-chip I/O areas not objects of cache
• Used in common with on-chip RAM; 2 kbytes of on-chip RAM used as address array/data
array when cache is enabled
Interrupt Controller (INTC):
• Nine external interrupt pins (NMI, IRQ0–IRQ7)
• Forty-three internal interrupt sources (forty-four for A mask)
• Sixteen programmable priority levels
User Break Controller (UBC):
• Generates an interrupt when the CPU or DMAC generates a bus cycle with specified
conditions
• Simplifies configuration of an on-chip debugger
Bus State Controller (BSC):
• Supports external extended memory access
16-bit (QFP-112, TQFP-120), or 32-bit (QFP-144) external data bus
• Memory address space divided into five areas (four areas of SRAM space, one area of DRAM
space) with the following settable features:
Bus size (8, 16, or 32 bits)
Number of wait cycles
2
Outputs chip-select signals for each area
During DRAM space access:
• Outputs RAS and CAS signals for DRAM
• Can generate a RAS precharge time assurance Tp cycle
• DRAM burst access function
Supports high-speed access mode for DRAM
• DRAM refresh function
Programmable refresh interval
Supports CAS-before-RAS refresh and self-refresh modes
• Wait cycles can be inserted using an external WAIT signal
• Address data multiplex I/O devices can be accessed
Direct Memory Access Controller (DMAC) (4 Channels):
• Supports cycle-steal transfers
• Supports dual address transfer mode
• Can be switched between direct and indirect transfer modes (channel 3 only)
Direct transfer mode: transfers the data at the transfer source address to the transfer
destination address
Indirect transfer mode: regards the data at the transfer source address as an address and
transfers the data at that address to the transfer destination address
Data Transfer Controller (DTC):
• Data transfer independent of the CPU possible through peripheral I/O interrupt requests
• Transfer mode can be set for each interrupt factor (transfer mode set in memory)
• Multiple data transfers possible for one activating factor
• Abundant transfer modes
Normal mode/repeat mode/block transfer mode selectable
• Transfer unit can be set to byte/word/longword
• Interrupts activating the DTC requested of the CPU
Interrupts can be generated to the CPU after completion of one data transfer
Interrupts can be generated to the CPU after completing all designated data transfers
• Transfer can be activated by software
Multifunction Timer/Pulse Unit (MTU):
• Maximum 16 types of waveform output or maximum 16 types of pulse I/O processing possible
based on 16-bit timer, 5 channels
• Phase-compensated PWM output mode
Non-overlapping waveform output for 6-phase inverter control
Automatic setting for dead time
PWM duty cycle can be set from 0 to 100%
Output off function
• Reset-synchronized PWM mode
3-phase output of any duty cycle positive phase/reverse phase PWM waveforms
Output the input sampling
acknowledgment of external DMA
transfer requests.
Output a strobe to the external I/O of
external DMA transfer requests.
SCI0, SCI1 transmit data output pins.
(TxD1 is used for data transfer during
boot mode of F-ZTAT)
SCI0, SCI1 receive data input pins.
(RxD1 is used for data transfer during
boot mode of F-ZTAT)
SCI0, SCI1 clock input/output pins.
Analog reference supply input pin.
(Connected to AV
QFP-112 and TQFP-120.)
External trigger input for A/D
conversion start.
internally in
CC
40
Table 1.7Pin Functions (cont)
ClassificationSymbolI/ONameFunction
I/O portsPOE0–
POE3
PA0–
PA15
(QFP-112)
PA0–
PA23
(QFP-144)
PB0–PB9I/OGeneral purpose
PC0–
PC15
PD0–
PD15
(QFP-112)
PD0–
PD31
(QFP-144)
PE0–
PE15
PF0–PF7IGeneral purpose
IPort output
enable
I/OGeneral purpose
port
port
I/OGeneral purpose
port
I/OGeneral purpose
port
I/OGeneral purpose
port
port
Input pin for port pin drive control
when general use ports are
established as output.
General purpose input/output port
pins.
Each bit can be designated for
input/output.
General purpose input/output port
pins.
Each bit can be designated for
input/output.
General purpose input/output port
pins.
Each bit can be designated for
input/output.
General purpose input/output port
pins.
Each bit can be designated for
input/output.
General purpose input/output port
pins.
Each bit can be designated for
input/output.
General purpose input port pins.
Usage Notes
1. Unused input pins should be pulled up or pulled down.
2. The WDTOVF pin should not be pulled down in the SH7044/SH7045 F-ZTAT version.
However, if it is necessary to pull this pin down, a resistance of 100 kΩ or higher should be
used.
41
1.4The F-ZTAT Version Onboard Programming
There are 2 modes on the F-ZTAT version: a mode that writes and overwrites programs using the
special writer and a mode that writes and overwrites programs onboard the application system.
When rebooting after setting each mode pin and FWP pin during the reset condition, the
microcomputer will transfer to one of the modes indicated in figure 1.6. In the user mode, data can
be read from the flash memory but cannot be written or deleted. Use the boot mode and the user
program mode to write to the flash memory or delete data.
In the boot mode, SCI1 (TXD1, RXD1) is used for data transfer. It is possible to automatically
adjust the transfer bit rate to the transfer bit rate of the host.
Table 1.8Pins during the Onboard Programming Mode
NotationI/OFunction
FWPInputHardware protected flash memory write/delete
MD1InputUser programming mode/boot mode setting
MD2InputClock mode (PLL) setting
MD3InputClock mode (PLL) setting
TxD1OutputSerial sent data output
RxD1InputSerial receive data input
*
1
D
M
User mode
FWP=0
Onboard programming mode
RES
FWP=1
User
program
mode
42
Power-on
1
=
P
reset condition
W
, F
1
=
0
=
RES=0
MD1=1, FWP=0
*
Boot mode
RES=0
MD1=1, FWP=0
Notes: For transferring between user mode and user program mode,
proceed while CPU is not programming or erasing the flash
memory.* RAM emulation permitted
Figure 1.6 Condition Transfer for Flash Memory
<Host>
Write control program
Application program
<SH7044/45>RXD1TXD1
Boot program
<Flash memory><RAM>
Write control
program area
SCI 1
Application program
Boot program area
Figure. 1.7 Data Transfer during Boot Mode
43
44
Section 2 CPU
2.1Register Configuration
The register set consists of sixteen 32-bit general registers, three 32-bit control registers and four
32-bit system registers.
2.1.1General Registers (Rn)
The sixteen 32-bit general registers (Rn) are numbered R0–R15. General registers are used for
data processing and address calculation. R0 is also used as an index register. Several instructions
have R0 fixed as their only usable register. R15 is used as the hardware stack pointer (SP). Saving
and recovering the status register (SR) and program counter (PC) in exception processing is
accomplished by referencing the stack using R15. Figure 2.1 shows the general registers.
Notes:
1
*
R0
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15, SP (hardware stack pointer)
*1*2R0 functions as an index register in the indirect indexed register addressing
mode and indirect indexed GBR addressing mode. In some instructions, R0
functions as a fixed source register or destination register.
R15 functions as a hardware stack pointer (SP) during exception processing.
031
2
*
Figure 2.1 General Registers
45
2.1.2Control Registers
The 32-bit control registers consist of the 32-bit status register (SR), global base register (GBR),
and vector base register (VBR). The status register indicates processing states. The global base
register functions as a base address for the indirect GBR addressing mode to transfer data to the
registers of on-chip peripheral modules. The vector base register functions as the base address of
the exception processing vector area (including interrupts). Figure 2.2 shows a control register.
SR
31
31
9876543210
M QI 3I2I1
GBR
ST
I0
SR: Status register
T bit: The MOVT, CMP/cond, TAS, TST,
BT (BT/S), BF (BF/S), SETT, and CLRT
instructions use the T bit to indicate true
(1) or false (0). The ADDV, ADDC,
SUBV, SUBC, DIV0U, DIV0S, DIV1,
NEGC, SHAR, SHAL, SHLR, SHLL,
ROTR, ROTL, ROTCR, and ROTCL
instructions also use the T bit to indicate
carry/borrow or overflow/underflow.
S bit: Used by the MAC instruction.
Reserved bits. This bit always read 0.
The write value should always be 0.
Bits I0–I3: Interrupt mask bits.
M and Q bits: Used by the DIV0U, DIV0S,
and DIV1 instructions.
Reserved bits. 0 is read. Write only.
0
Global base register (GBR):
Indicates the base address of the indirect
GBR addressing mode. The indirect GBR
addressing mode is used in data transfer
for on-chip peripheral modules register
areas and in logic operations.
46
VBR
031
Vector base register (VBR):
Stores the base address of the exception
processing vector area.
Figure 2.2 Control Registers
2.1.3System Registers
System registers consist of four 32-bit registers: high and low multiply and accumulate registers
(MACH and MACL), the procedure register (PR), and the program counter (PC). The multiply
and accumulate registers store the results of multiply and accumulate operations. The procedure
register stores the return address from the subroutine procedure. The program counter stores
program addresses to control the flow of the processing. Figure 2.3 shows a system register.
310
MACH
MACL
31
PR
31
PC
Multiply and accumulate (MAC)
registers high and low (MACH,
MACL): Stores the results of
multiply and accumulate operations.
0
Procedure register (PR): Stores
a return address from a
subroutine procedure.
0
Program counter (PC): Indicates
the fourth byte (second instruction)
after the current instruction.
Figure 2.3 System Registers
2.1.4 Initial Values of Registers
Table 2.1 lists the values of the registers after reset.
Table 2.1Initial Values of Registers
ClassificationRegisterInitial Value
General registersR0–R14Undefined
R15 (SP)Value of the stack pointer in the vector address table
Control registersSRBits I3–I0 are 1111 (H'F), reserved bits are 0, and other
bits are undefined
GBRUndefined
VBRH'00000000
System registersMACH, MACL, PRUndefined
PC Value of the program counter in the vector address table
47
2.2Data Formats
2.2.1Data Format in Registers
Register operands are always longwords (32 bits). When the memory operand is only a byte (8
bits) or a word (16 bits), it is sign-extended into a longword when loaded into a register (figure
2.4).
310
Longword
Figure 2.4 Longword Operand
2.2.2Data Format in Memory
Memory data formats are classified into bytes, words, and longwords. Byte data can be accessed
from any address, but an address error will occur if you try to access word data starting from an
address other than 2n or longword data starting from an address other than 4n. In such cases, the
data accessed cannot be guaranteed. The hardware stack area, referred to by the hardware stack
pointer (SP, R15), uses only longword data starting from address 4n because this area holds the
program counter and status register (figure 2.5).
Address m + 1Address m + 3
Address mAddress m + 2
31015
Address 2n
Address 4n
237
ByteByteByteByte
WordWord
Longword
Figure 2.5 Byte, Word, and Longword Alignment
2.2.3Immediate Data Format
Byte (8-bit) immediate data resides in an instruction code. Immediate data accessed by the MOV,
ADD, and CMP/EQ instructions is sign-extended and handled in registers as longword data.
Immediate data accessed by the TST, AND, OR, and XOR instructions is zero-extended and
handled as longword data. Consequently, AND instructions with immediate data always clear the
upper 24-bits of the destination register.
48
Word or longword immediate data is not located in the instruction code, but instead is stored in a
memory table. An immediate data transfer instruction (MOV) accesses the memory table using the
PC relative addressing mode with displacement.
2.3Instruction Features
2.3.1RISC-Type Instruction Set
All instructions are RISC type. This section details their functions.
16-Bit Fixed Length: All instructions are 16 bits long, increasing program code efficiency.
One Instruction per Cycle: The microprocessor can execute basic instructions in one cycle using
the pipeline system. Instructions are executed in 35 ns at 28.7 MHz.
Data Length: Longword is the standard data length for all operations. Memory can be accessed in
bytes, words, or longwords. Byte or word data accessed from memory is sign-extended and
handled as longword data. Immediate data is sign-extended for arithmetic operations or zeroextended for logic operations. It also is handled as longword data (table 2.2).
Table 2.2Sign Extension of Word Data
SH7040 Series CPUDescriptionExample of Conventional CPU
MOV.W @(disp,PC),R1
ADDR1,R0
.........
.DATA.WH'1234
Note: @(disp, PC) accesses the immediate data.
Data is sign-extended to 32
bits, and R1 becomes
H'00001234. It is next
operated upon by an ADD
instruction.
ADD.W#H'1234,R0
Load-Store Architecture: Basic operations are executed between registers. For operations that
involve memory access, data is loaded to the registers and executed (load-store architecture).
Instructions such as AND that manipulate bits, however, are executed directly in memory.
Delayed Branch Instructions: Unconditional branch instructions are delayed. Executing the
instruction that follows the branch instruction and then branching reduces pipeline disruption
during branching (table 2.3). There are two types of conditional branch instructions: delayed
branch instructions and ordinary branch instructions.
49
Table 2.3Delayed Branch Instructions
SH7040 Series CPUDescriptionExample of Conventional CPU
BRA TRGET
ADD R1,R0
Executes an ADD before
branching to TRGET
ADD.W R1,R0
BRATRGET
Multiplication/Accumulation Operation: 16-bit × 16-bit → 32-bit multiplication operations are
executed in one to two cycles. 16-bit × 16-bit + 64-bit → 64-bit multiplication/accumulation
operations are executed in two to three cycles. 32-bit × 32-bit → 64-bit and 32-bit × 32-bit + 64bit → 64-bit multiplication/accumulation operations are executed in two to four cycles.
T Bit: The T bit in the status register changes according to the result of the comparison, and in
turn is the condition (true/false) that determines if the program will branch. The number of
instructions that change the T bit is kept to a minimum to improve the processing speed (table
2.4).
Table 2.4T Bit
SH7040 Series CPUDescriptionExample of Conventional CPU
CMP/GER1,R0
BTTRGET0
BFTRGET1
ADD#1,R0
CMP/EQ#0,R0
BTTRGET
T bit is set when R0 ≥ R1. The
program branches to TRGET0
when R0 ≥ R1 and to TRGET1
when R0 < R1.
T bit is not changed by ADD. T bit is
set when R0 = 0. The program
branches if R0 = 0.
CMP.WR1,R0
BGETRGET0
BLTTRGET1
SUB.W#1,R0
BEQTRGET
Immediate Data: Byte (8-bit) immediate data resides in instruction code. Word or longword
immediate data is not input via instruction codes but is stored in a memory table. An immediate
data transfer instruction (MOV) accesses the memory table using the PC relative addressing mode
with displacement (table 2.5).
50
Table 2.5Immediate Data Accessing
ClassificationSH7040 Series CPUExample of Conventional CPU
Absolute Address: When data is accessed by absolute address, the value already in the absolute
address is placed in the memory table. Loading the immediate data when the instruction is
executed transfers that value to the register and the data is accessed in the indirect register
addressing mode (table 2.6).
Table 2.6Absolute Address Accessing
ClassificationSH7040 Series CPUExample of Conventional CPU
Absolute addressMOV.L@(disp,PC),R1
MOV.B@R1,R0
..................
.DATA.LH'12345678
Note: @(disp,PC) accesses the immediate data.
MOV.B@H'12345678,R0
16-Bit/32-Bit Displacement: When data is accessed by 16-bit or 32-bit displacement, the preexisting displacement value is placed in the memory table. Loading the immediate data when the
instruction is executed transfers that value to the register and the data is accessed in the indirect
indexed register addressing mode (table 2.7).
Table 2.7Displacement Accessing
ClassificationSH7040 Series CPUExample of Conventional CPU
16-bit displacementMOV.W@(disp,PC),R0
MOV.W@(R0,R1),R2
..................
.DATA.WH'1234
Note: @(disp,PC) accesses the immediate data.
MOV.W@(H'1234,R1),R2
51
2.3.2Addressing Modes
Table 2.8 describes addressing modes and effective address calculation.
RnThe effective address is register Rn. (The operand
is the contents of register Rn.)
@RnThe effective address is the content of register Rn.
RnRn
@Rn+The effective address is the content of register Rn.
A constant is added to the content of Rn after the
instruction is executed. 1 is added for a byte
operation, 2 for a word operation, and 4 for a
longword operation.
RnRn
Rn + 1/2/4
1/2/4
@–RnThe effective address is the value obtained by
subtracting a constant from Rn. 1 is subtracted for
a byte operation, 2 for a word operation, and 4 for
a longword operation.
Rn
Rn – 1/2/4
1/2/4
+
–
Rn – 1/2/4
—
Rn
Rn
(After the
instruction
executes)
Byte: Rn + 1
→ Rn
Word: Rn + 2
→ Rn
Longword:
Rn + 4 → Rn
Byte: Rn – 1
→ Rn
Word: Rn – 2
→ Rn
Longword:
Rn – 4 → Rn
(Instruction
executed with
Rn after
calculation)
52
Table 2.8Addressing Modes and Effective Addresses (cont)
@(R0, Rn) The effective address is the Rn value plus R0.
@(disp:8,
GBR)
The effective address is Rn plus a 4-bit
displacement (disp). The value of disp is zeroextended, and remains the same for a byte
operation, is doubled for a word operation, and is
quadrupled for a longword operation.
Rn
disp
(zero-extended)
1/2/4
Rn
R0
The effective address is the GBR value plus an
8-bit displacement (disp). The value of disp is zeroextended, and remains the same for a byte operation, is doubled for a word operation, and is
quadrupled for a longword operation.
GBR
disp
(zero-extended)
+
×
+
×
Rn + disp × 1/2/4
Rn + R0
+
+ disp × 1/2/4
GBR
Byte: Rn +
disp
Word: Rn +
disp × 2
Longword: Rn
+ disp × 4
Rn + R0
Byte: GBR +
disp
Word: GBR +
disp × 2
Longword:
GBR + disp ×
4
1/2/4
53
Table 2.8Addressing Modes and Effective Addresses (cont)
@(R0, GBR) The effective address is the GBR value plus the R0.
GBR
@(disp:8,
PC)
+
R0
The effective address is the PC value plus an 8-bit
displacement (disp). The value of disp is zeroextended, and is doubled for a word operation, and
quadrupled for a longword operation. For a
longword operation, the lowest two bits of the PC
value are masked.
PC
(for longword)
&
H'FFFFFFFC
disp
(zero-extended)
+
×
GBR + R0
PC + disp × 2
or
PC & H'FFFFFFFC
+ disp × 4
GBR + R0
Word: PC +
disp × 2
Longword:
PC &
H'FFFFFFFC
+ disp × 4
54
2/4
Table 2.8Addressing Modes and Effective Addresses (cont)
disp:8The effective address is the PC value sign-extended
with an 8-bit displacement (disp), doubled, and
added to the PC value.
PC
disp
(sign-extended)
2
disp:12The effective address is the PC value sign-extended
with a 12-bit displacement (disp), doubled, and
added to the PC value.
PC
disp
(sign-extended)
2
RnThe effective address is the register PC value
plus Rn.
+
PC + disp × 2
×
+
PC + disp × 2
×
PC + disp × 2
PC + disp × 2
PC + Rn
Immediate
addressing
PC
+
Rn
#imm:8The 8-bit immediate data (imm) for the TST, AND,
OR, and XOR instructions are zero-extended.
#imm:8The 8-bit immediate data (imm) for the MOV, ADD,
and CMP/EQ instructions are sign-extended.
#imm:8The 8-bit immediate data (imm) for the TRAPA
instruction is zero-extended and is quadrupled.
PC + Rn
—
—
—
55
2.3.3Instruction Format
Table 2.9 lists the instruction formats for the source operand and the destination operand. The
meaning of the operand depends on the instruction code. The symbols are used as follows:
Note: * In multiply/accumulate instructions, nnnn is the source register.
nnnn: Direct
register
MOV.L
@(disp,Rm),Rn
57
Table 2.9Instruction Formats (cont)
Instruction Formats
d format
150
xxxx
d12 format
150
xxxx
xxxx
dddd
dddd
dddddddd
dddd
Source Operand Destination
OperandExample
dddddddd:
Indirect GBR
with
displacement
R0(Direct
register)
dddddddd: PC
relative with
displacement
dddddddd: PC
relative
dddddddddddd:
PC relative
R0 (Direct register) MOV.L
dddddddd: Indirect
GBR with
displacement
R0 (Direct register) MOVA
—BF label
—BRA label
@(disp,GBR),R0
MOV.L
R0,@(disp,GBR)
@(disp,PC),R0
(label = disp +
PC)
nd8 format
150
xxxx
nnnn
i formatiiiiiiii: ImmediateIndirect indexed
150
xxxxxxxxi i i i
ni format
150
xxxx
nnnn
dddd
i i i i
i i i i
dddd
i i i i
dddddddd: PC
relative with
displacement
iiiiiiii: ImmediateR0 (Direct register) AND #imm,R0
iiiiiiii: Immediate—TRAPA #imm
iiiiiiii: Immediatennnn: Direct
nnnn: Direct
register
GBR
register
MOV.L
@(disp,PC),Rn
AND.B
#imm,@(R0,GBR)
ADD #imm,Rn
58
2.4Instruction Set by Classification
Table 2.10 Classification of Instructions
Operation
Classification Types
Data transfer5MOVData transfer, immediate data transfer,
Arithmetic21ADDBinary addition33
operations
CodeFunction
peripheral module data transfer, structure data
transfer
MOVAEffective address transfer
MOVTT bit transfer
SWAPSwap of upper and lower bytes
XTRCTExtraction of the middle of registers connected
ADDC Binary addition with carry
ADDVBinary addition with overflow check
CMP/cond Comparison
DIV1Division
DIV0SInitialization of signed division
DIV0UInitialization of unsigned division
DMULSSigned double-length multiplication
DMULUUnsigned double-length multiplication
DTDecrement and test
EXTSSign extension
EXTUZero extension
MAC Multiply/accumulate, double-length
multiply/accumulate operation
MULDouble-length multiply operation
MULSSigned multiplication
MULUUnsigned multiplication
NEGNegation
NEGC Negation with borrow
SUBBinary subtraction
SUBC Binary subtraction with borrow
SUBVBinary subtraction with underflow
No. of
Instructions
39
59
Table 2.10 Classification of Instructions (cont)
Operation
Classification Types
Logic6ANDLogical AND14
operations
Shift10ROTLOne-bit left rotation14
Branch9BFConditional branch, conditional branch with
CodeFunction
NOTBit inversion
ORLogical OR
TASMemory test and bit set
TSTLogical AND and T bit set
XORExclusive OR
ROTROne-bit right rotation
ROTCLOne-bit left rotation with T bit
ROTCROne-bit right rotation with T bit
SHALOne-bit arithmetic left shift
SHAROne-bit arithmetic right shift
SHLLOne-bit logical left shift
SHLLnn-bit logical left shift
SHLROne-bit logical right shift
SHLRnn-bit logical right shift
delay (Branch when T = 0)
BTConditional branch, conditional branch with
delay (Branch when T = 1)
BRAUnconditional branch
BRAFUnconditional branch
BSRBranch to subroutine procedure
BSRFBranch to subroutine procedure
JMPUnconditional branch
JSRBranch to subroutine procedure
RTSReturn from subroutine procedure
No. of
Instructions
11
60
Table 2.10 Classification of Instructions (cont)
Operation
Classification Types
System11CLRTT bit clear31
control
Total: 62142
CodeFunction
CLRMAC MAC register clear
LDC Load to control register
LDSLoad to system register
NOPNo operation
RTEReturn from exception processing
SETTT bit set
SLEEPShift into power-down mode
STC Storing control register data
STSStoring system register data
TRAPATrap exception handling
No. of
Instructions
Table 2.11 shows the format used in tables 2.12 to 2.17, which list instruction codes, operation,
and execution states in order by classification.
61
Table 2.11 Instruction Code Format
ItemFormatExplanation
InstructionOP.Sz SRC,DESTOP: Operation code
Sz: Size (B: byte, W: word, or L: longword)
SRC: Source
DEST: Destination
Rm: Source register
Rn: Destination register
imm: Immediate data
disp: Displacement
Instruction
code
MSB ↔ LSBmmmm: Source register
nnnn: Destination register
0000: R0
0001: R1
1111: R15
iiii: Immediate data
dddd: Displacement
Operation→, ←Direction of transfer
(xx)Memory operand
M/Q/TFlag bits in the SR
&Logical AND of each bit
|Logical OR of each bit
^Exclusive OR of each bit
~Logical NOT of each bit
<<nn-bit left shift
>>nn-bit right shift
Execution
—Value when no wait states are inserted
cycles
T bit—Value of T bit after instruction is executed. An em-dash (—)
in the column means no change.
Notes: *1 Depending on the operand size, displacement is scaled ×1, ×2, or ×4. For details, see
the SH-1/SH-2/SH-DSP Programming Manual.
*2 Instruction execution cycles: The execution cycles shown in the table are minimums.
The actual number of cycles may be increased when (1) contention occurs between
instruction fetches and data access, or (2) when the destination register of the load
instruction (memory → register) and the register used by the next instruction are the
same.
1
*
.
.
.
2
*
62
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.