– SPI synchronous serial interface
– SCI asynchronous serial interface
■ 1 Analog Peripheral
– 10-bit ADC with up to 12 input ports
■ Instruction Set
– 8-bit Data Manipulation
– 63 Basic Instructions
– 17 main Addressing Modes
– 8 x 8 Unsigned Multiply Instruction
■ Development Tools
– Full hardware/software development package
– In-Circuit Testing capability
7 x 7
SDIP32
400 mil
Table 1. Device Summary
Features
Program memory bytes
RAM (stack) - bytes1024 (256)512 (256)384 (256)
Voltage Range 2.85 to 3.6V
Temp. Range up to -40°C to +85°C
PackagesLQFP44 10x10 (J), LQFP48 7x7 (S), SDIP32, LQFP32 7x7 (K)
The ST72F324L and ST72324BL devices are
members of the ST7 microcontroller family de
signed for mid-range applications running at 3.3V.
Different package options offer up to 32 I/O pins.
All devices are based on a common industrystandard 8-bit core, featuring an enhanced instruc
tion set and are available with Flash or ROM program memory. The ST7 family architecture offers
both power and flexibility to software developers,
Figure 1. Device Block Diagram
8-BIT CORE
ALU
RESET
V
PP
V
SS
V
DD
OSC1
OSC2
PF7:6,4,2:0
(6 bits on J and S devices)
(5 bits on K devices)
PE1:0
(2 bits)
(6 bits on J and S devices)
(2 bits on K devices)
PD5:0
V
AREF
V
SSA
CONTROL
OSC
MCC/RTC/BEEP
PORT F
TIMER A
BEEP
PORT E
SCI
PORT D
10-BIT ADC
-
-
enabling the design of highly efficient and compact
application code.
The on-chip peripherals include an A/D converter,
2 general purpose timers, an SPI interface and an
SCI interface.
For power economy, microcontroller can switch
dynamically into WAIT, SLOW, ACTIVE-HALT or
HALT mode when the application is in idle or
stand-by state.
Typical applications are consumer, home, office
and industrial products.
PROGRAM
MEMORY
(8K - 32K Bytes)
RAM
(384 - 2048 Bytes)
WATCHDOG
ADDRESS AND DATA BUS
PORT A
PORT B
PORT C
TIMER B
SPI
PA7:3
(5 bits on J and S devices)
(4 bits on K devices)
PB4:0
(5 bits on J and S devices)
(3 bits on K devices)
PC7:0
(8 bits)
6/154
3
2 PIN DESCRIPTION
Figure 2. 48-Pin LQFP 7x7 Device Pinout
ST72324Lxx
AIN0 / PD0
AIN1 / PD1
AIN3 / PD2
AIN4 / PD3
Legend
NC = Not Connected (not bonded)
NC
NC
PB0
PB1
PB2
PB3
(HS) PB4
NC
_2
DD
PE1/ RDI
PE0 / TDO
V
48 47 46 45
_2
/ICCSEL
SS
OSC2
OSC1
PP
V
RESET
V
44 43 42 41 40 39 38 37
1
2
3
4
ei2
5
6
ei3
7
8
9
10
11
12
ei1
13 14 15 16 17 18 19 20 21 22
SSA
AREF
V
V
AIN4 / PD4
AIN5 / PD5
(HS) PF2
BEEP / (HS) PF1
MCO / AIN8 / PF0
OCMP1_A / AIN10 / PF4
PA7 (HS)
ICAP1_A / (HS) PF6
PA6 (HS)
PA5 (HS)
PA4 (HS)
V
36
SS_1
V
35
DD_1
PA3 (HS)
34
NC
33
PC7 / SS / AIN15
32
ei0
23
DD_0
V
PC6 / SCK / ICCCLK
31
30
PC5 / MOSI / AIN14
29
PC4 / MISO / ICCDATA
28
PC3 (HS) / ICAP1_B
27
PC2 (HS) / ICAP2_B
26
PC1 / OCMP1_B / AIN13
25
PC0 / OCMP2_B / AIN12
24
SS_0
V
EXTCLK_A / (HS) PF7
(HS) 20mA high sink capability
eix associated external interrupt vector
(HS) 8mA high sink capability
eix associated external interrupt vector
V
AREF
V
MCO / AIN8 / PF0
BEEP / (HS) PF1
OCMP1_A / AIN10 / PF4
ICAP1_A / (HS) PF6
EXTCLK_A / (HS) PF7
AIN12 / OCMP2_B / PC0
SSA
PB0
PD1 / AIN1
PD0 / AIN0
PB4 (HS)
32 31 30 29 28 27 26 25
1
ei3
2
3
ei1
4
5
6
7
8
9 10111213141516
ICAP2_B / (HS) PC2
ICAP1_B / (HS) PC3
AIN13 / OCMP1_B / PC1
PB3
ei2
ICCDATA / MISO / PC4
AIN14 / MOSI / PC5
PE1 / RDI
ICCCLK / SCK / PC6
PE0 / TDO
ei0
AIN15 / SS / PC7
_2
DD
V
24
23
22
21
20
19
18
17
(HS) PA3
OSC1
OSC2
VSS_2
RESET
V
/ ICCSEL
PP
PA7 (HS)
PA6 (HS)
PA4 (HS)
(HS) 8mA high sink capability
eix associated external interrupt vector
9/154
1
ST72324Lxx
PIN DESCRIPTION (Cont’d)
For more details, refer to “ELECTRICAL CHARACTERISTICS” on page 110
Legend / Abbreviations for Table 2:
Type: I = input, O = output, S = supply
In/Output level: C = CMOS
CT= CMOS with input trigger
Output level: HS = high sink (on N-buffer only)
Port and control configuration:
– Input:float = floating, wpu = weak pull-up, int = interrupt
– Output: OD = open drain
2)
, PP = push-pull
Refer to “I/O PORTS” on page 40 for more details on the software configuration of the I/O ports.
The RESET configuration of each pin is shown in bold. This configuration is valid as long as the device is
in reset state.
Table 2. Device Pin Description
1)
, ana = analog ports
Pin n°
LQFP48
LQFP44
SDIP32
LQFP32
Pin Name
LevelPort
Type
Input
Output
float
InputOutput
wpu
int
ana
OD
function
(after
reset)
PP
Main
Alternate Function
7 6 30 1 PB4 (HS)I/O CTHSXei3XXPort B4
9 7 31 2 PD0/AIN0I/O C
10 8 32 3 PD1/AIN1I/O C
11 9PD2/AIN2I/O C
12 10PD3/AIN3I/O C
13 11PD4/AIN4I/O C
14 12PD5/AIN5I/O C
15 13 1 4 V
16 14 2 5 V
AREF
SSA
SAnalog Reference Voltage for ADC
SAnalog Ground Voltage
17 15 3 6 PF0/MCO/AIN8I/O C
T
T
T
T
T
T
T
XXXXXPort D0 ADC Analog Input 0
XXXXXPort D1 ADC Analog Input 1
XXXXXPort D2 ADC Analog Input 2
XXXXXPort D3 ADC Analog Input 3
XXXXXPort D4 ADC Analog Input 4
XXXXXPort D5 ADC Analog Input 5
5)
Xei1XXXPort F0
Main clock
out (f
OSC
ADC Analog
/2)
Input 8
18 16 4 7 PF1 (HS)/BEEPI/O CTHSXei1XXPort F1 Beep signal output
19 17PF2 (HS)I/O CTHSXei1XXPort F2
SDigital Main Supply Voltage
47 44 26 29 PE0/TDOI/O C
48 1 27 30 PE1/RDII/O C
3 2 28 31 PB0I/O C
4 3PB1I/O C
5 4PB2I/O C
6 5 29 32 PB3I/O C
T
T
T
T
T
T
XXXXPort E0 SCI Transmit Data Out
XXXXPort E1 SCI Receive Data In
Xei2XXPort B0
Xei2XXPort B1
Xei2XXPort B2
Xei2XXPort B3
External clock input or Resonator oscillator inverter input
5)
Notes:
1. In the interrupt input column, “eiX” defines the associated external interrupt vector. If the weak pull-up
column (wpu) is merged with the interrupt column (int), then the I/O configuration is pull-up interrupt input,
else the configuration is floating interrupt input.
2. In the open drain output column, “T” defines a true open drain I/O (P-Buffer and protection diode to V
DD
11/154
1
ST72324Lxx
are not implemented). See See “I/O PORTS” on page 40. and Section 12.8 I/O PORT PIN CHARACTER-
ISTICS for more details.
3. OSC1 and OSC2 pins connect a crystal/ceramic resonator, or an external source to the on-chip oscillator; see Section 2 PIN DESCRIPTION and Section 12.5 CLOCK AND TIMING CHARACTERISTICS for
more details.
4. On the chip, each I/O port has 8 pads. Pads that are not bonded to external pins are in input pull-up configuration after reset. The configuration of these pads must be kept at reset state to avoid added current
consumption.
5. It is mandatory to connect all available VDD and VREF pins to the supply voltage and all VSS and
VSSA pins to ground.
12/154
1
3 REGISTER & MEMORY MAP
ST72324Lxx
As shown in Figure 6, the MCU is capable of addressing 64K bytes of memories and I/O registers.
The available memory locations consist of 128
bytes of register locations, up to 1024 bytes of
RAM and up to 32 Kbytes of user program memo
ry. The RAM space includes up to 256 bytes for
the stack from 0100h to 01FFh.
Figure 6. Memory Map
0000h
007Fh
0080h
087Fh
0880h
7FFFh
8000h
FFDFh
FFE0h
FFFFh
HW Registers
(see Table 3)
RAM
(1024,
512 or 384 Bytes)
Reserved
Program Memory
(32K, 16K or 8K)
Interrupt & Reset Vectors
(see Table 9)
0080h
00FFh
0100h
01FFh
0200h
027Fh
or 047Fh
The highest address bytes contain the user reset
and interrupt vectors.
IMPORTANT: Memory locations marked as “Reserved” must never be accessed. Accessing a reserved area can have unpredictable effects on the
device.
Short Addressing
RAM (zero page)
256 Bytes Stack
16-bit Addressing
RAM
8000h
C000h
E000h
FFFFh
32 KBytes
16 KBytes
8 Kbytes
13/154
1
ST72324Lxx
Table 3. Hardware Register Map
AddressBlock
0000h
0001h
Port A
0002h
0003h
0004h
Port B
0005h
0006h
0007h
Port C
0008h
0009h
000Ah
Port D
000Bh
000Ch
000Dh
Port E
000Eh
000Fh
0010h
Port F
0011h
0012h
to
0020h
Register
Label
2)
PADR
PADDR
PAOR
2)
PBDR
PBDDR
PBOR
PCDR
PCDDR
PCOR
2)
PDADR
PDDDR
PDOR
2)
PEDR
PEDDR
PEOR
2)
PFDR
PFDDR
PFOR
Port A Data Register
Port A Data Direction Register
Port A Option Register
Port B Data Register
Port B Data Direction Register
Port B Option Register
Port C Data Register
Port C Data Direction Register
Port C Option Register
Port D Data Register
Port D Data Direction Register
Port D Option Register
Port E Data Register
Port E Data Direction Register
Port E Option Register
Port F Data Register
Port F Data Direction Register
Port F Option Register
Register Name
Reset
Status
1)
00h
00h
00h
1)
00h
00h
00h
1)
00h
00h
00h
1)
00h
00h
00h
1)
00h
00h
00h
1)
00h
00h
00h
Remarks
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
2)
R/W
2)
R/W
R/W
R/W
R/W
Reserved Area (15 Bytes)
0021h
0022h
0023h
0024h
0025h
0026h
0027h
SPI
ITC
SPIDR
SPICR
SPICSR
ISPR0
ISPR1
ISPR2
ISPR3
SPI Data I/O Register
SPI Control Register
SPI Control/Status Register
Timer A Control Register 2
Timer A Control Register 1
Timer A Control/Status Register
Timer A Input Capture 1 High Register
Timer A Input Capture 1 Low Register
Timer A Output Compare 1 High Register
Timer A Output Compare 1 Low Register
Timer A Counter High Register
Timer A Counter Low Register
Timer A Alternate Counter High Register
Timer A Alternate Counter Low Register
Timer A Input Capture 2 High Register
Timer A Input Capture 2 Low Register
Timer A Output Compare 2 High Register
Timer A Output Compare 2 Low Register
Timer B Control Register 2
Timer B Control Register 1
Timer B Control/Status Register
Timer B Input Capture 1 High Register
Timer B Input Capture 1 Low Register
Timer B Output Compare 1 High Register
Timer B Output Compare 1 Low Register
Timer B Counter High Register
Timer B Counter Low Register
Timer B Alternate Counter High Register
Timer B Alternate Counter Low Register
Timer B Input Capture 2 High Register
Timer B Input Capture 2 Low Register
Timer B Output Compare 2 High Register
Timer B Output Compare 2 Low Register
3)4)
Reset
Status
00h
00h
xxxx x0xxb
xxh
xxh
80h
00h
FFh
FCh
FFh
3)
3)
4)
4)
FCh
xxh
xxh
80h
00h
00h
00h
xxxx x0xxb
xxh
xxh
80h
00h
FFh
FCh
FFh
FCh
xxh
xxh
80h
00h
Remarks
R/W
R/W
R/W
Read Only
Read Only
R/W
R/W
Read Only
Read Only
Read Only
Read Only
Read Only
Read Only
R/W
R/W
R/W
R/W
R/W
Read Only
Read Only
R/W
R/W
Read Only
Read Only
Read Only
Read Only
Read Only
Read Only
R/W
R/W
0050h
0051h
0052h
0053h
0054h
0055h
0056h
0057h
0058h
to
006Fh
0070h
0071h
0072h
0073h
007Fh
SCI
ADC
SCISR
SCIDR
SCIBRR
SCICR1
SCICR2
SCIERPR
SCIETPR
ADCCSR
ADCDRH
ADCDRL
SCI Status Register
SCI Data Register
SCI Baud Rate Register
SCI Control Register 1
SCI Control Register 2
SCI Extended Receive Prescaler Register
Reserved area
SCI Extended Transmit Prescaler Register
Reserved Area (24 Bytes)
Control/Status Register
Data High Register
Data Low Register
Reserved Area (13 Bytes)
C0h
xxh
00h
x000 0000h
00h
00h
---
00h
00h
00h
00h
Read Only
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Read Only
Read Only
15/154
1
ST72324Lxx
Legend: x=undefined, R/W=read/write
Notes:
1. The contents of the I/O port DR registers are readable only in output configuration. In input configuration, the values of the I/O pins are returned instead of the DR register contents.
2. The bits associated with unavailable pins must always keep their reset value.
3. The Timer A Input Capture 2 pin is not available (not bonded).
– In Flash devices:
The TAIC2HR and TAIC2LR registers are not present. Bit 4 of the TACSR register (ICF2) is forced
by hardware to 0. Consequently, the corresponding interrupt cannot be used.
4. The Timer A Output Compare 2 pin is not available (not bonded).
– In ROM devices:
The TAOC2HR and TAOC2LR Registers can be used in PWM mode or for timebase generation.
– In Flash devices:
The TAOC2HR and TAOC2LR Registers are write only, reading them will return undefined values.
Bit 3 of the TACSR register (OCF2) is forced by hardware to 0. Consequently, the corresponding interrupt cannot be used.
Caution: The TAIC2HR and TAIC2LR registers and the ICF2 and OCF2 flags are not present in the
ST72F324L but are present in the emulator. For compatibility with the emulator, it is recommended to per
form a dummy access (read or write) to the TAIC2LR and TAOC2LR registers to clear the interrupt flags.
-
16/154
1
4 FLASH PROGRAM MEMORY
ST72324Lxx
4.1 Introduction
The ST7 dual voltage High Density Flash
(HDFlash) is a non-volatile memory that can be
electrically erased as a single block or by individu
al sectors and programmed on a Byte-by-Byte basis using an external VPP supply.
The HDFlash devices can be programmed and
erased off-board (plugged in a programming tool)
or on-board using ICP (In-Circuit Programming) or
IAP (In-Application Programming).
The array matrix organisation allows each sector
to be erased and reprogrammed without affecting
other sectors.
4.2 Main Features
■ Three Flash programming modes:
– Insertion in a programming tool. In this mode,
all sectors including option bytes can be pro
-
grammed or erased.
– ICP (In-Circuit Programming). In this mode, all
sectors including option bytes can be pro
-
grammed or erased without removing the device from the application board.
– IAP (In-Application Programming) In this
mode, all sectors except Sector 0, can be pro
-
grammed or erased without removing the device from the application board and while the
application is running.
■ ICT (In-Circuit Testing) for downloading and
executing user application test patterns in RAM
■ Read-out protection
■ Register Access Security System (RASS) to
prevent accidental programming or erasing
4.3 Structure
The Flash memory is organised in sectors and can
be used for both code and data storage.
Depending on the overall Flash memory size in the
microcontroller device, there are up to three user
sectors (see
Table 4). Each of these sectors can
be erased independently to avoid unnecessary
erasing of the whole Flash memory when only a
partial erasing is required.
The first two sectors have a fixed size of 4 Kbytes
Figure 7). They are mapped in the upper part
(see
of the ST7 addressing space so the reset and interrupt vectors are located in Sector 0 (F000hFFFFh).
Table 4. Sectors available in Flash devices
Flash Size (bytes)Available Sectors
4KSector 0
8KSectors 0,1
> 8KSectors 0,1, 2
4.3.1 Read-out Protection
Read-out protection, when selected, provides a
protection against Program Memory content ex
traction and against write access to Flash memory. Even if no protection can be considered as totally unbreakable, the feature provides a very high
level of protection for a general purpose microcon
troller.
In flash devices, this protection is removed by reprogramming the option. In this case, the entire
program memory is first automatically erased.
Read-out protection selection depends on the device type:
– In Flash devices it is enabled and removed
through the FMP_R bit in the option byte.
– In ROM devices it is enabled by mask option
specified in the Option List.
Figure 7. Memory Map and Sector Address
4K10K24K48K
1000h
3FFFh
7FFFh
9FFFh
BFFFh
D7FFh
DFFFh
EFFFh
FFFFh
8K16K32K60K
2Kbytes
8Kbytes40 Kbytes
16 Kbytes
4 Kbytes
4 Kbytes
24 Kbytes
FLASH
MEMORY SIZE
SECTOR 2
52 Kbytes
SECTOR 1
SECTOR 0
17/154
1
ST72324Lxx
FLASH PROGRAM MEMORY (Cont’d)
4.4 ICC Interface
ICC needs a minimum of 5 and up to 6 pins to be
connected to the programming tool (see
Figure 8).
These pins are:
– RESET: device reset
–VSS: device power supply ground
Figure 8. Typical ICC Interface
PROGRAMMING TOOL
APPLICATION
POWER SUPPLY
(See Note 3)
DD
V
OSC2
(See Note 4)
OSC1
ST7
SS
V
Notes:
1. If the ICCCLK or ICCDATA pins are only used
as outputs in the application, no signal isolation is
necessary. As soon as the Programming Tool is
plugged to the board, even if an ICC session is not
in progress, the ICCCLK and ICCDATA pins are
not available for the application. If they are used as
inputs by the application, isolation such as a serial
resistor has to implemented in case another de
vice forces the signal. Refer to the Programming
Tool documentation for recommended resistor val
ues.
2. During the ICC session, the programming tool
must control the
flicts between the programming tool and the application reset circuit if it drives more than 5mA at
high level (push pull output or pull-up resistor<1K).
A schottky diode can be used to isolate the appli
cation RESET circuit in this case. When using a
classical RC network with R>1K or a reset man
RESET pin. This can lead to con-
– ICCCLK: ICC output serial clock pin
– ICCDATA: ICC input/output serial data pin
– ICCSEL/VPP: programming voltage
– OSC1(or OSCIN): main clock input for exter-
nal source
–VDD: application board power supply (option-
al, see Figure 8, Note 3)
ICC CONNECTOR
975 3
10kΩ
ICCSEL/VPP
ICC Cable
RESET
ICCCLK
HE10 CONNECTOR TYPE
1
246810
ICCDATA
APPLICATION BOARD
ICC CONNECTOR
APPLICATION
RESET SOURCE
See Note 2
See Note 1
APPLICATION
I/O
agement IC with open drain output and pull-up resistor>1K, no additional components are needed.
In all cases the user must ensure that no external
reset is generated by the application during the
ICC session.
3. The use of Pin 7 of the ICC connector depends
on the Programming Tool architecture. This pin
-
must be connected when using most ST Program
ming Tools (it is used to monitor the application
-
power supply). Please refer to the Programming
Tool manual.
4. External clock ICC entry mode is mandatory in
this device. Pin 9 must be connected to the OSC1
or OSCIN pin of the ST7 and OSC2 must be
grounded.
-
-
-
18/154
1
FLASH PROGRAM MEMORY (Cont’d)
ST72324Lxx
4.5 ICP (In-Circuit Programming)
To perform ICP the microcontroller must be
switched to ICC (In-Circuit Communication) mode
by an external controller or programming tool us
-
ing 36-pulse mode.
Depending on the ICP code downloaded in RAM,
Flash memory programming can be fully custom
ized (number of bytes to program, program locations, or selection serial communication interface
for downloading).
When using an STMicroelectronics or third-party
programming tool that supports ICP and the spe
cific microcontroller device, the user needs only to
implement the ICP hardware interface on the ap
plication board (see Figure 8). For more details on
the pin locations, refer to the device pinout description.
4.6 IAP (In-Application Programming)
This mode uses a BootLoader program previously
stored in Sector 0 by the user (in ICP mode or by
plugging the device in a programming tool).
This mode is fully controlled by user software. This
allows it to be adapted to the user application, (us
er-defined strategy for entering programming
mode, choice of communications protocol used to
fetch the data to be stored, etc.). For example, it is
possible to download code from the SPI, SCI, USB
or CAN interface and program it in the Flash. IAP
mode can be used to program any of the Flash
sectors except Sector 0, which is write/erase pro
tected to allow recovery in case errors occur during the programming operation.
4.7 Related Documentation
For details on Flash programming and ICC protocol, refer to the ST7 Flash Programming Reference Manual and to the ST7 ICC Protocol Refer-
This register is reserved for use by Programming
Tool software. It controls the Flash programming
and erasing operations.
-
Table 5. Flash Control/Status Register Address and Reset Value
Address
(Hex.)
0029h
Register
Label
FCSR
Reset Value00000000
76543210
19/154
1
ST72324Lxx
5 CENTRAL PROCESSING UNIT
5.1 INTRODUCTION
This CPU has a full 8-bit architecture and contains
six internal registers allowing efficient 8-bit data
manipulation.
5.2 MAIN FEATURES
■ Enable executing 63 basic instructions
■ Fast 8-bit by 8-bit multiply
■ 17 main addressing modes (with indirect
addressing mode)
■ Two 8-bit index registers
■ 16-bit stack pointer
■ Low power HALT and WAIT modes
■ Priority maskable hardware interrupts
■ Non-maskable software/hardware interrupts
Figure 9. CPU Registers
5.3 CPU REGISTERS
The six CPU registers shown in Figure 9 are not
present in the memory mapping and are accessed
by specific instructions.
Accumulator (A)
The Accumulator is an 8-bit general purpose register used to hold operands and the results of the
arithmetic and logic calculations and to manipulate
data.
Index Registers (X and Y)
These 8-bit registers are used to create effective
addresses or as temporary storage areas for data
manipulation. (The Cross-Assembler generates a
precede instruction (PRE) to indicate that the fol
lowing instruction refers to the Y register.)
The Y register is not affected by the interrupt automatic procedures.
Program Counter (PC)
The program counter is a 16-bit register containing
the address of the next instruction to be executed
by the CPU. It is made of two 8-bit registers PCL
(Program Counter Low which is the LSB) and PCH
(Program Counter High which is the MSB).
-
70
RESET VALUE = XXh
70
RESET VALUE = XXh
70
RESET VALUE = XXh
158
RESET VALUE = RESET VECTOR @ FFFEh-FFFFh
15
RESET VALUE = STACK HIGHER ADDRESS
PCH
RESET VALUE =
7
70
1C1I1HI0NZ
1X11X1XX
70
8
PCL
0
ACCUMULATOR
X INDEX REGISTER
Y INDEX REGISTER
PROGRAM COUNTER
CONDITION CODE REGISTER
STACK POINTER
X = Undefined Value
20/154
1
CENTRAL PROCESSING UNIT (Cont’d)
Condition Code Register (CC)
Read/Write
Reset Value: 111x1xxx
70
11I1HI0NZ
C
The 8-bit Condition Code register contains the interrupt masksand four flags representative of the
result of the instruction just executed. This register
can also be handled by the PUSH and POP in
structions.
These bits can be individually tested and/or controlled by specific instructions.
Arithmetic Management Bits
Bit 4 = H Half carry.
This bit is set by hardware when a carry occurs be-
tween bits 3 and 4 of the ALU during an ADD or
ADC instructions. It is reset by hardware during
the same instructions.
0: No half carry has occurred.
1: A half carry has occurred.
This bit is tested using the JRH or JRNH instruction. The H bit is useful in BCD arithmetic subroutines.
Bit 2 = N Negative.
This bit is set and cleared by hardware. It is repre-
sentative of the result sign of the last arithmetic,
logical or data manipulation. It’s a copy of the re
sult 7th bit.
0: The result of the last operation is positive or null.
1: The result of the last operation is negative
(that is, the most significant bit is a logic 1).
This bit is accessed by the JRMI and JRPL instructions.
ST72324Lxx
Bit 1 = Z Zero.
This bit is set and cleared by hardware. This bit in-
dicates that the result of the last arithmetic, logical
or data manipulation is zero.
0: The result of the last operation is different from
zero.
1: The result of the last operation is zero.
This bit is accessed by the JREQ and JRNE test
instructions.
Bit 0 = C Carry/borrow.
This bit is set and cleared by hardware and soft-
-
ware. It indicates an overflow or an underflow has
occurred during the last arithmetic operation.
0: No overflow or underflow has occurred.
1: An overflow or underflow has occurred.
This bit is driven by the SCF and RCF instructions
and tested by the JRC and JRNC instructions. It is
also affected by the “bit test and branch”, shift and
rotate instructions.
Interrupt Management Bits
Bit 5,3 = I1, I0 Interrupt
The combination of the I1 and I0 bits gives the cur-
These two bits are set/cleared by hardware when
entering in interrupt. The loaded value is given by
the corresponding bits in the interrupt software pri
ority registers (IxSPR). They can be also set/
cleared by software with the RIM, SIM, IRET,
HALT, WFI and PUSH/POP instructions.
See the interrupt management chapter for more
details.
-
21/154
1
ST72324Lxx
CENTRAL PROCESSING UNIT (Cont’d)
Stack Pointer (SP)
Read/Write
Reset Value: 01 FFh
158
00000001
70
SP7SP6SP5SP4SP3SP2SP1
SP0
The Stack Pointer is a 16-bit register which is always pointing to the next free location in the stack.
It is then decremented after data has been pushed
onto the stack and incremented before data is
popped from the stack (see
Figure 10).
Since the stack is 256 bytes deep, the 8 most significant bits are forced by hardware. Following an
MCU Reset, or after a Reset Stack Pointer instruc
tion (RSP), the Stack Pointer contains its reset value (the SP7 to SP0 bits are set) which is the stack
higher address.
Figure 10. Stack Manipulation Example
CALL
Subroutine
Interrupt
Event
PUSH YPOP YIRET
The least significant byte of the Stack Pointer
(called S) can be directly accessed by a LD in
-
struction.
Note: When the lower limit is exceeded, the Stack
Pointer wraps around to the stack upper limit, with
out indicating the stack overflow. The previously
stored information is then overwritten and there
fore lost. The stack also wraps in case of an underflow.
The stack is used to save the return address during a subroutine call and the CPU context during
an interrupt. The user may also directly manipulate
the stack by means of the PUSH and POP instruc
tions. In the case of an interrupt, the PCL is stored
at the first location pointed to by the SP. Then the
other registers are stored in the next locations as
shown in
Figure 10.
– When an interrupt is received, the SP is decre-
mented and the context is pushed on the stack.
– On return from interrupt, the SP is incremented
and the context is popped from the stack.
A subroutine call occupies two locations and an interrupt five locations in the stack area.
If the clock frequency input to the PLL is in the
range 2 to 4 MHz, the PLL can be used to multiply
the frequency by two to obtain an f
OSC2
of 4 to 8
MHz. The PLL is enabled by option byte. If the PLL
is disabled, then f
OSC2 = fOSC
/2.
Caution: The PLL is not recommended for applications where timing accuracy is required. See
Section 6.1 on page 23.
Caution: The PLL must not be used with the internal RC oscillator.
0
f
OSC2
1
PLL OPTION BIT
MAIN CLOCK
CONTROLLER
WITH REALTIME
CLOCK (MCC/RTC)
f
CPU
RESET
RESET SEQUENCE
MANAGER
(RSM)
WATCHDOG
TIMER (WDG)
23/154
1
ST72324Lxx
6.2 MULTI-OSCILLATOR (MO)
The main clock of the ST7 can be generated by
three different source types coming from the multioscillator block:
■ an external source
■ 4 crystal or ceramic resonator oscillators
■ an internal high frequency RC oscillator
Each oscillator is optimized for a given frequency
range in terms of consumption and is selectable
through the option byte. The associated hardware
configurations are shown in
Table 6. Refer to the
electrical characteristics section for more details.
Caution: The OSC1 and/or OSC2 pins must not
be left unconnected. For the purposes of Failure
Mode and Effect Analysis, it should be noted that if
the OSC1 and/or OSC2 pins are left unconnected,
the ST7 main oscillator may start and, in this con
figuration, could generate an f
clock frequency
OSC
-
in excess of the allowed maximum (>16MHz.),
putting the ST7 in an unsafe/undefined state. The
product behaviour must therefore be considered
undefined when the OSC pins are left unconnect
-
ed.
External Clock Source
In this external clock mode, a clock signal (square,
sinus or triangle) with ~50% duty cycle has to drive
the OSC1 pin while the OSC2 pin is tied to ground.
Crystal/Ceramic Oscillators
This family of oscillators has the advantage of producing a very accurate rate on the main clock of
the ST7. The selection within a list of 4 oscillators
with different frequency ranges has to be done by
option byte in order to reduce consumption (refer
Section 14.1 on page 140 for more details on
to
the frequency ranges). In this mode of the multioscillator, the resonator and the load capacitors
have to be placed as close as possible to the oscil
lator pins in order to minimize output distortion and
start-up stabilization time. The loading capacitance values must be adjusted according to the
selected oscillator.
These oscillators are not stopped during the
RESET phase to avoid losing time in the oscillator
start-up phase.
Internal RC Oscillator
This oscillator allows a low cost solution for the
main clock of the ST7 using only an internal resis
tor and capacitor. Internal RC oscillator mode has
the drawback of a lower frequency accuracy and
should not be used in applications that require ac
curate timing.
In this mode, the two oscillator pins have to be tied
to ground.
The reset sequence manager includes two RESET sources as shown in Figure 13:
■ External RESET source pulse
■ Internal WATCHDOG RESET
These sources act on the RESET pin and it is always kept low during the delay phase.
The RESET service routine vector is fixed at addresses FFFEh-FFFFh in the ST7 memory map.
The basic RESET sequence consists of 3 phases
as shown in
■ Active Phase depending on the RESET source
■ 256 or 4096 CPU clock cycle delay (selected by
Figure 12:
option byte)
■ RESET vector fetch
The 256 or 4096 CPU clock cycle delay allows the
oscillator to stabilise and ensures that recovery
has taken place from the Reset state. The shorter
or longer clock cycle delay should be selected by
option byte to correspond to the stabilization time
of the external oscillator used in the application.
The RESET vector fetch phase duration is 2 clock
cycles.
Figure 12. RESET Sequence Phases
RESET
Active Phase
INTERNAL RESET
256 or 4096 CLOCK CYCLES
FETCH
VECTOR
6.3.2 Asynchronous External RESET pin
The RESET pin is both an input and an open-drain
output with integrated R
This pull-up has no fixed value but varies in ac
weak pull-up resistor.
ON
cordance with the input voltage. It can be pulled
low by external circuitry to reset the device. See
Electrical Characteristic section for more details.
A RESET signal originating from an external
source must have a duration of at least t
h(RSTL)in
order to be recognized. This detection is asynchro
in
nous and therefore the MCU can enter reset state
even in HALT mode.
The RESET pin is an asynchronous signal which
plays a major role in EMS performance. In a noisy
environment, it is recommended to follow the
guidelines mentioned in the electrical characteris
tics section.
6.3.3 External Power-On RESET
To start up the microcontroller correctly, the user
must ensure by means of an external reset circuit
that the reset signal is held low until V
the minimum level specified for the selected f
is over
DD
OSC
frequency.
A proper reset signal for a slow rising VDD supply
can generally be provided by an external RC net
work connected to the RESET pin.
6.3.4 Internal Watchdog RESET
Starting from the Watchdog counter underflow, the
device
low during at least t
RESET pin acts as an output that is pulled
w(RSTL)out
.
Figure 13. Reset Block Diagram
V
DD
R
ON
RESET
Filter
PULSE
GENERATOR
INTERNAL
RESET
WATCHDOG RESET
25/154
1
ST72324Lxx
7 INTERRUPTS
7.1 INTRODUCTION
The ST7 enhanced interrupt management provides the following features:
■ Hardware interrupts
■ Software interrupt (TRAP)
■ Nested or concurrent interrupt management
with flexible interrupt priority and level
management:
– Up to 4 software programmable nesting levels
– Up to 16 interrupt vectors fixed by hardware
– 2 non maskable events: RESET, TRAP
This interrupt management is based on:
– Bit 5 and bit 3 of the CPU CC register (I1:0),
– Interrupt software priority registers (ISPRx),
– Fixed interrupt vector addresses located at the
high addresses of the memory map (FFE0h to
FFFFh) sorted by hardware priority order.
This enhanced interrupt controller guarantees full
upward compatibility with the standard (not nest
-
ed) ST7 interrupt controller.
7.2 MASKING AND PROCESSING FLOW
The interrupt masking is managed by the I1 and I0
bits of the CC register and the ISPRx registers
which give the interrupt software priority level of
each interrupt vector (see
Table 7). The process-
ing flow is shown in Figure 14
When an interrupt request has to be serviced:
– Normal processing is suspended at the end of
the current instruction execution.
– The PC, X, A and CC registers are saved onto
the stack.
– I1 and I0 bits of CC register are set according to
the corresponding values in the ISPRx registers
of the serviced interrupt vector.
– The PC is then loaded with the interrupt vector of
the interrupt to service and the first instruction of
the interrupt service routine is fetched (refer to
“Interrupt Mapping” table for vector addresses).
The interrupt service routine should end with the
IRET instruction which causes the contents of the
saved registers to be recovered from the stack.
Note: As a consequence of the IRET instruction,
the I1 and I0 bits will be restored from the stack
and the program in the previous level will resume.
As several interrupts can be pending at the same
time, the interrupt to be taken into account is deter
-
mined by the following two-step process:
– the highest software priority interrupt is serviced,
– if several interrupts have the same software pri-
ority then the interrupt with the highest hardware
priority is serviced first.
Figure 15 describes this decision process.
Figure 15. Priority Decision Process
PENDING
INTERRUPTS
Same
HIGHEST HARDWARE
PRIORITY SERVICED
SOFTWARE
PRIORITY
HIGHEST SOFTWARE
PRIORITY SERVICED
Different
When an interrupt request is not serviced immediately, it is latched and then processed when its
software priority combined with the hardware pri
-
ority becomes the highest one.
Note 1: The hardware priority is exclusive while
the software one is not. This allows the previous
process to succeed with only one interrupt.
Note 2: RESET and TRAP can be considered as
having the highest software priority in the decision
process.
Different Interrupt Vector Sources
Two interrupt source types are managed by the
ST7 interrupt controller: the non-maskable type
(RESET, TRAP) and the maskable type (external
or from internal peripherals).
Non-Maskable Sources
These sources are processed regardless of the
state of the I1 and I0 bits of the CC register (see
Figure 14). After stacking the PC, X, A and CC
registers (except for RESET), the corresponding
vector is loaded in the PC register and the I1 and
I0 bits of the CC are set to disable interrupts (level
3). These sources allow the processor to exit
HALT mode.
■ TRAP (Non Maskable Software Interrupt)
This software interrupt is serviced when the TRAP
instruction is executed. It will be serviced accord
ing to the flowchart in Figure 14.
■ RESET
The RESET source has the highest priority in the
ST7. This means that the first current routine has
the highest software priority (level 3) and the high
est hardware priority.
See the RESET chapter for more details.
Maskable Sources
Maskable interrupt vector sources can be serviced
if the corresponding interrupt is enabled and if its
own interrupt software priority (in ISPRx registers)
is higher than the one currently being serviced (I1
and I0 in CC register). If any of these two condi
tions is false, the interrupt is latched and thus remains pending.
■ External Interrupts
External interrupts allow the processor to exit from
HALT low power mode. External interrupt sensitiv
ity is software selectable through the External Interrupt Control register (EICR).
External interrupt triggered on edge will be latched
and the interrupt request automatically cleared
upon entering the interrupt service routine.
If several input pins of a group connected to the
same interrupt line are selected simultaneously,
these will be logically ORed.
■ Peripheral Interrupts
Usually the peripheral interrupts cause the MCU to
exit from HALT mode except those mentioned in
the “Interrupt Mapping” table. A peripheral inter
rupt occurs when a specific flag is set in the peripheral status registers and if the corresponding
enable bit is set in the peripheral control register.
The general sequence for clearing an interrupt is
based on an access to the status register followed
by a read or write to an associated register.
Note: The clearing sequence resets the internal
latch. A pending interrupt (i.e. waiting for being
serviced) will therefore be lost if the clear se
quence is executed.
27/154
1
ST72324Lxx
INTERRUPTS (Cont’d)
7.3 INTERRUPTS AND LOW POWER MODES
All interrupts allow the processor to exit the WAIT
low power mode. On the contrary, only external
and other specified interrupts allow the processor
to exit from the HALT modes (see column “Exit
from HALT” in “Interrupt Mapping” table). When
several pending interrupts are present while exit
ing HALT mode, the first one serviced can only be
an interrupt with exit from HALT mode capability
and it is selected through the same decision proc
ess shown in Figure 15.
Note: If an interrupt, that is not able to Exit from
HALT mode, is pending with the highest priority
when exiting HALT mode, this interrupt is serviced
after the first one serviced.
Figure 16. Concurrent Interrupt Management
TRAP
IT0
TRAP
IT0
IT1
RIM
IT2
IT2
IT1
IT4
IT3
IT1
HARDWARE PRIORITY
MAIN
11 / 10
7.4 CONCURRENT & NESTED MANAGEMENT
The following Figure 16 and Figure 17 show two
different interrupt management modes. The first is
called concurrent mode and does not allow an in
terrupt to be interrupted, unlike the nested mode in
Figure 17. The interrupt hardware priority is given
in this order from the lowest to the highest: MAIN,
IT4, IT3, IT2, IT1, IT0. The software priority is giv
en for each interrupt.
Warning: A stack overflow may occur without notifying the software of the failure.
SOFTWARE
PRIORITY
LEVEL
IT3
IT4
MAIN
3
3
3
3
3
3
3/0
I1
11
11
11
11
11
11
I0
USED STACK = 10 BYTES
10
-
-
Figure 17. Nested Interrupt Management
IT4
IT3
TRAP
TRAP
IT0
HARDWARE PRIORITY
MAIN
RIM
IT2
IT2
IT1
IT1
IT4
11 / 10
28/154
1
IT4
IT0
IT3
IT1
SOFTWARE
PRIORITY
LEVEL
IT2
10
MAIN
I1I0
3
3
2
1
3
3
3/0
11
11
00
01
11
11
USED STACK = 20 BYTES
INTERRUPTS (Cont’d)
7.5 INTERRUPT REGISTER DESCRIPTION
ST72324Lxx
CPU CC REGISTER INTERRUPT BITS
Read / Write
Reset Value: 111x 1010 (xAh)
70
11I1HI0NZC
Bit 5, 3 = I1, I0 Software Interrupt Priority
These two bits indicate the current interrupt soft-
These two bits are set/cleared by hardware when
entering in interrupt. The loaded value is given by
the corresponding bits in the interrupt software pri
ority registers (ISPRx).
They can be also set/cleared by software with the
RIM, SIM, HALT, WFI, IRET and PUSH/POP in
structions (see “Interrupt Dedicated Instruction
Set” table).
*Note: TRAP and RESET events can interrupt a
level 3 program.
INTERRUPT SOFTWARE PRIORITY REGISTERS (ISPRX)
Read/Write (bit 7:4 of ISPR3 are read only)
Reset Value: 1111 1111 (FFh)
70
ISPR0I1_3 I0_3 I1_2 I0_2 I1_1 I0_1 I1_0 I0_0
ISPR1I1_7 I0_7 I1_6 I0_6 I1_5 I0_5 I1_4 I0_4
ISPR2I1_11 I0_11 I1_10 I0_10 I1_9 I0_9 I1_8 I0_8
ISPR31111I1_13 I0_13 I1_12 I0_12
These four registers contain the interrupt software
priority of each interrupt vector.
– Each interrupt vector (except RESET and TRAP)
has corresponding bits in these registers where
its own software priority is stored. This corre
-
spondance is shown in the following table.
Vector addressISPRx bits
FFFBh-FFFAhI1_0 and I0_0 bits*
FFF9h-FFF8hI1_1 and I0_1 bits
......
FFE1h-FFE0hI1_13 and I0_13 bits
– Each I1_x and I0_x bit value in the ISPRx regis-
ters has the same meaning as the I1 and I0 bits
in the CC register.
– Level 0 can not be written (I1_x=1, I0_x=0). In
this case, the previously stored value is kept. (ex
-
ample: previous=CFh, write=64h, result=44h)
The RESET, and TRAP vectors have no software
priorities. When one is serviced, the I1 and I0 bits
of the CC register are both set.
Caution: If the I1_x and I0_x bits are modified
while the interrupt x is executed the following be
haviour has to be considered: If the interrupt x is
still pending (new interrupt or flag not cleared) and
the new software priority is higher than the previ
ous one, the interrupt x is re-entered. Otherwise,
the software priority stays unchanged up to the
next interrupt request (after the IRET of the inter
HALTEntering Halt mode10
IRETInterrupt routine returnPop CC, A, X, PCI1HI0NZC
JRMJump if I1:0=11 (level 3)I1:0=11 ?
JRNMJump if I1:0<>11I1:0<>11 ?
POP CCPop CC from the StackMem => CCI1HI0NZC
RIMEnable interrupt (level 0 set)Load 10 in I1:0 of CC10
SIMDisable interrupt (level 3 set)Load 11 in I1:0 of CC11
TRAPSoftware trapSoftware NMI11
WFIWait for interrupt10
Note: During the execution of an interrupt routine, the HALT, POPCC, RIM, SIM and WFI instructions change the current
software priority up to the next IRET instruction or one of the previously mentioned instructions.
30/154
1
Loading...
+ 124 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.