ST72T141K2MARE [STMICROELECTRONICS]

8-bit MCU for automotive with electric-motor control, ADC, 16-bit timers, SPI interface; 8位MCU的汽车与电动马达控制, ADC , 16位定时器, SPI接口
ST72T141K2MARE
型号: ST72T141K2MARE
厂家: ST    ST
描述:

8-bit MCU for automotive with electric-motor control, ADC, 16-bit timers, SPI interface
8位MCU的汽车与电动马达控制, ADC , 16位定时器, SPI接口

文件: 总131页 (文件大小:3091K)
中文:  中文翻译
下载:  下载PDF数据表文档文件
ST72141K2-Auto  
8-bit MCU for automotive with electric-motor control,  
ADC, 16-bit timers, SPI interface  
Memories  
– 8 Kbytes Program memory (OTP/EPROM)  
– 256 bytes RAM  
Clock, Reset and Supply Management  
– Enhanced reset system  
– Low voltage supply supervisor  
– 3 power saving modes  
14 I/O Ports  
– 14 multifunctional bidirectional I/O lines with:  
External interrupt capability (2 vectors), 13 al-  
ternate function lines, 3 high sink outputs  
SO34S  
Motor Control peripheral  
– 6 PWM output channels  
– Emergency pin to force outputs to HiZ state  
– 3 analog inputs for rotor position detection  
with no need for additional sensors  
– Comparator for current limitation  
3 Timers  
Instruction Set  
– Two 16-bit timers with: 2 input captures, 2 out-  
put compares, external clock input, PWM and  
Pulse generator modes  
– 8-bit data manipulation  
– 63 basic instructions  
– 17 main addressing modes  
– 8 x 8 unsigned multiply instruction  
– True bit manipulation  
– Watchdog timer for system integrity  
Communications Interface  
– SPI synchronous serial interface  
Analog Peripheral  
Development Tools  
– Full hardware/software development package  
– 8-bit ADC with 8 input pins  
Device Summary  
Features  
Program memory - bytes  
RAM (stack) - bytes  
ST72141K2-Auto  
8K  
256 (64)  
Motor control,  
Watchdog, Two 16-bit timers,  
SPI, ADC  
Peripherals  
Operating Supply  
4V to 5.5V  
CPU Frequency  
Operating Temperature  
Packages  
4 or 8 MHz (with 8 or 16 MHz oscillator)  
-40°C to +85°C  
SO34  
Rev. 1  
November 2007  
1/131  
1
Table of Contents  
1 GENERAL DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5  
1.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5  
1.2 PIN DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6  
1.3 EXTERNAL CONNECTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9  
1.4 REGISTER AND MEMORY MAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10  
1.5 EPROM PROGRAM MEMORY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13  
2 CENTRAL PROCESSING UNIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14  
2.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14  
2.2 MAIN FEATURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14  
2.3 CPU REGISTERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14  
3 SUPPLY, RESET AND CLOCK MANAGEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17  
3.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17  
3.2 MAIN FEATURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17  
3.3 LOW VOLTAGE DETECTOR (LVD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18  
3.4 RESET MANAGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19  
3.5 LOW CONSUMPTION OSCILLATOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23  
3.6 MAIN CLOCK CONTROLLER (MCC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24  
4 INTERRUPTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25  
4.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25  
4.2 NON-MASKABLE SOFTWARE INTERRUPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25  
4.3 EXTERNAL INTERRUPTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25  
4.4 PERIPHERAL INTERRUPTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25  
5 POWER SAVING MODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27  
5.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27  
5.2 HALT MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28  
5.3 WAIT MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29  
5.4 SLOW MODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29  
6 I/O PORTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30  
6.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30  
6.2 FUNCTIONAL DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30  
6.2.1 Input Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30  
6.2.2 Output Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30  
6.2.3 Alternate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30  
6.3 I/O PORT IMPLEMENTATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33  
6.3.1 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35  
7 MISCELLANEOUS REGISTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37  
7.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37  
7.2 I/O PORT INTERRUPT SENSITIVITY DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . 37  
7.3 I/O PORT ALTERNATE FUNCTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37  
7.4 CLOCK PRESCALER SELECTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37  
7.5 MISCELLANEOUS REGISTER DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38  
8 ON-CHIP PERIPHERALS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39  
2/131  
2
Table of Contents  
8.1 MOTOR CONTROLLER (MTC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39  
8.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39  
8.1.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39  
8.1.3 Application Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39  
8.1.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43  
8.1.5 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65  
8.1.6 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65  
8.1.7 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66  
8.2 WATCHDOG TIMER (WDG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74  
8.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74  
8.2.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74  
8.2.3 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75  
8.2.4 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75  
8.2.5 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75  
8.2.6 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75  
8.3 16-BIT TIMER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77  
8.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77  
8.3.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77  
8.3.3 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77  
8.3.4 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89  
8.3.5 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89  
8.3.6 Summary of Timer modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89  
8.3.7 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90  
8.4 SERIAL PERIPHERAL INTERFACE (SPI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95  
8.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95  
8.4.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95  
8.4.3 General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95  
8.4.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97  
8.4.5 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104  
8.4.6 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104  
8.4.7 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105  
8.5 8-BIT A/D CONVERTER (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108  
8.5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108  
8.5.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108  
8.5.3 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109  
8.5.4 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109  
8.5.5 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109  
8.5.6 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110  
9 INSTRUCTION SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111  
9.1 ST7 ADDRESSING MODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111  
9.1.1 Inherent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112  
9.1.2 Immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112  
9.1.3 Direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112  
9.1.4 Indexed (No Offset, Short, Long) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112  
9.1.5 Indirect (Short, Long) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112  
9.1.6 Indirect Indexed (Short, Long) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113  
9.1.7 Relative Mode (Direct, Indirect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113  
9.2 INSTRUCTION GROUPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114  
3/131  
3
Table of Contents  
10 ELECTRICAL CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117  
10.1 ABSOLUTE MAXIMUM RATINGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117  
10.2 RECOMMENDED OPERATING CONDITIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118  
10.3 DC ELECTRICAL CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118  
10.4 GENERAL TIMING CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118  
10.5 I/O PORT CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119  
10.6 SUPPLY, RESET AND CLOCK CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . 120  
10.6.1Supply Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120  
10.6.2RESET Sequence Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120  
10.6.3Clock System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120  
10.7 MEMORY AND PERIPHERAL CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . 121  
11 GENERAL INFORMATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127  
11.1 PACKAGE CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127  
11.1.1Package Mechanical Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127  
11.2 ECOPACK® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127  
11.3 ORDERING INFORMATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127  
12 SUMMARY OF CHANGES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130  
4/131  
1
ST72141K2-Auto  
1 GENERAL DESCRIPTION  
1.1 INTRODUCTION  
The ST72141K2-Auto devices are members of the  
ST7 microcontroller family designed specifically  
for motor control applications and including A/D  
conversion and SPI interface capabilities. They in-  
clude an on-chip Motor Controller peripheral for  
control of electric brushless motors with or without  
sensors. An example application, for 6-step con-  
trol of a Permanent Magnet DC motor, is shown in  
Figure 1.  
Figure 1. Example of a 6-step-controlled Motor  
ST7  
300V  
6
MCO5-0  
0
2
4
B
MCIB  
I
6
I
1
MTC  
I
4
I
3
A
MCIA  
MCIC  
The ST72141K2-Auto devices are based on a  
common industry-standard 8-bit core, featuring an  
enhanced instruction set.  
C
I
I
5
2
3
5
1
2
Under software control, they can be placed in  
WAIT, SLOW, or HALT mode, reducing power  
consumption when the application is in idle or  
standby state.  
Net  
Step  
Σ
Σ
Σ
Σ
Σ
Σ
Σ
Σ
Σ
3
1
2
3
4
5
6
1
0
1
2
3
4
5
The enhanced instruction set and addressing  
modes of the ST7 offer both power and flexibility to  
software developers, enabling the design of highly  
efficient and compact application code. In addition  
to standard 8-bit data management, all ST7 micro-  
controllers feature true bit manipulation, 8x8 un-  
signed multiplication and indirect addressing  
modes.  
300V  
150V  
0
A
B
C
300V  
150V  
0
300V  
150V  
0
Figure 2. Device Block Diagram  
Internal  
OSC1  
CLOCK  
PORT A  
OSC  
DIV  
OSC2  
VDD  
8-BIT ADC  
TIMER B  
PA7:0  
(8-bit)  
POWER  
SUPPLY  
LVD  
VSS  
TIMER A  
OC1A  
CONTROL  
RESET  
MCO5:0  
8-bit CORE  
ALU  
MCIA:C  
MCES  
MOTOR CTRL  
MCCFI  
8 Kbyte EPROM  
256 byte RAM  
PORT B  
SPI  
PB5:0  
(6-bit)  
WATCHDOG  
5/131  
4
ST72141K2-Auto  
1.2 PIN DESCRIPTION  
Figure 3. 34-Pin SO Package Pinout  
MCIA  
MCIB  
MCIC  
34  
33  
32  
MCO5  
1
MCO4  
MCO3  
2
3
MCCFI  
MCO2  
MCO1  
31  
30  
29  
28  
27  
26  
25  
24  
23  
22  
21  
20  
19  
18  
4
V
5
DD  
V
MCO0  
6
SS  
V
MCES  
7
PP  
OCMP1_A  
MISO/PB5  
8
NC  
NC  
MOSI/PB4  
SCK/PB3  
9
PA7/AIN7/OCMP2_A  
PA6/AIN6/ICAP1_A  
10  
11 EI1  
12  
SS/ (HS) PB2  
EXTCLK_B/ (HS) PB1  
EXTCLK_A/ (HS) PB0  
OSC1  
PA5/AIN5/ICAP2_A  
PA4/AIN4/OCMP1_B  
PA3/AIN3/OCMP2_B  
13  
14  
EI0  
PA2/AIN2/ICAP1_B  
PA1/AIN1/ICAP2_B  
PA0/AIN0  
15  
OSC2  
16  
17  
RESET  
6/131  
5
ST72141K2-Auto  
PIN DESCRIPTION (Cont’d)  
Legend / Abbreviations:  
Type:  
I = input, O = output, S = supply  
A = Dedicated analog input  
Input level:  
In/Output level: C = CMOS 0.3V /0.7V  
DD  
DD  
DD  
C = CMOS 0.3V /0.7V with input trigger  
T
DD  
Output level:  
HS = high sink (on N-buffer only),  
R = 70/100ratio of logical levels.  
Analog level if used as PWM filtered with an external capacitor  
Port configuration capabilities:  
– Input:  
float = floating, wpu = weak pull-up, int = interrupt, ana = analog  
OD = open drain, T = true open drain, PP = push-pull  
– Output:  
Note: The Reset configuration of each pin is shown in bold.  
Table 1. SO34 Device Pin Description  
Level  
Port / Control  
Main  
Function  
(after reset)  
Pin  
No.  
Input  
Output  
Pin Name  
Alternate Function  
1
2
3
4
5
6
7
8
9
MCO5  
O
O
O
O
O
O
I
C
C
C
C
C
C
X
X
X
X
X
X
Motor Control Output Channel 5  
Motor Control Output Channel 4  
Motor Control Output Channel 3  
Motor Control Output Channel 2  
Motor Control Output Channel 1  
Motor Control Output Channel 0  
Motor Control Emergency Stop Input  
MCO4  
MCO3  
MCO2  
MCO1  
MCO0  
MCES  
PB5/MISO  
NC  
C
X
T
I/O  
C
X
EI1  
X
X
Port B5  
SPI Master In / Slave Out Data  
T
T
Not Connected  
10 PB4/MOSI  
11 PB3/SCK  
12 PB2/SS  
I/O  
I/O  
I/O  
I/O  
I/O  
C
C
X
X
X
X
X
EI1  
EI1  
EI1  
EI1  
EI1  
X
X
T
T
T
X
X
Port B4  
Port B3  
Port B2  
Port B1  
Port B0  
SPI Master Out / Slave In Data  
SPI Serial Clock  
T
C
C
C
HS  
SPI Slave Select (active low)  
Timer B Input Clock  
T
13 PB1/EXTCLK_B  
14 PB0/EXTCLK_A  
15 OSC1  
HS  
HS  
T
T
Timer A Input Clock  
These pins connect a crystal or ceramic resona-  
tor, or an external RC, or an external source to  
the on-chip oscillator.  
16 OSC2  
17 RESET  
I/O  
I/O  
C
X
X
X
Top priority non-maskable interrupt (active low)  
18 PA0/AIN0  
C
X
X
EI0  
X
X
X
X
Port A0  
Port A1  
ADC Analog Input 0  
T
T
Timer B Input Capture 2 or ADC  
Analog Input 1  
19 PA1/ICAP2_B/AIN1  
20 PA2/ICAP1_B/AIN2  
I/O  
I/O  
C
C
C
EI0  
EI0  
EI0  
X
X
X
Timer B Input Capture 1 or ADC  
Analog Input 2  
X
X
X
X
X
X
Port A2  
Port A3  
T
T
Timer B Output Compare 2 or  
ADC Analog Input 3  
21 PA3/OCMP2_B/AIN3 I/O  
7/131  
6
ST72141K2-Auto  
Level  
Port / Control  
Main  
Function  
(after reset)  
Pin  
Input  
Output  
Pin Name  
No.  
Alternate Function  
Timer B Output Compare 1 or  
ADC Analog Input 4  
22 PA4/OCMP1_B/AIN4 I/O  
C
C
C
C
X
X
X
X
EI0  
EI0  
EI0  
EI0  
X
X
X
X
X
X
X
X
X
X
X
X
Port A4  
Port A5  
Port A6  
Port A7  
T
T
T
T
Timer A Input Capture 2 or ADC  
Analog Input 5  
23 PA5/ICAP2_A/AIN5  
24 PA6/ICAP1_A/AIN6  
I/O  
I/O  
Timer A Input Capture 1 or ADC  
Analog Input 6  
Timer A Output Compare 2 or  
ADC Analog Input 7  
25 PA7/OCMP2_A/AIN7 I/O  
26 NC  
Not Connected  
27 OCMP1_A  
O
I
R
Timer A Output Compare 1  
EPROM Programming voltage pin (must be tied  
low during normal operating mode)  
28  
V
PP  
29  
30  
V
V
S
S
I
Ground  
SS  
DD  
Main power supply  
31 MCCFI  
32 MCIC  
33 MCIB  
34 MCIA  
A
A
A
A
Motor Control Current Feedback Input  
Motor Control Input C  
Motor Control Input B  
Motor Control Input A  
I
I
I
8/131  
ST72141K2-Auto  
1.3 EXTERNAL CONNECTIONS  
The following figure shows the recommended ex-  
ternal connections for the device.  
The external reset network is intended to protect  
the device against parasitic resets, especially in  
noisy environments.  
The V pin is only used for programming OTP  
PP  
and EPROM devices and must be tied to ground in  
user mode.  
Unused I/Os should be tied high to avoid any un-  
necessary power consumption on floating lines.  
An alternative solution is to program the unused  
ports as inputs with pull-up.  
The 10nF and 0.1µF decoupling capacitors on the  
power supply lines are a suggested EMC perform-  
ance/cost tradeoff.  
Figure 4. Recommended External Connections  
V
V
PP  
DD  
SS  
V
DD  
+
0.1µF  
10µF  
V
Optional if Low Voltage  
Detector (LVD) is used  
V
DD  
V
V
DD  
4.7K  
0.1µF  
0.1µF  
SS  
RESET  
EXTERNAL RESET CIRCUIT  
See  
Clocks  
Section  
OSC1  
OSC2  
Or configure unused I/O ports  
by software as input with pull-up  
10K  
V
DD  
Unused I/O  
9/131  
ST72141K2-Auto  
1.4 REGISTER AND MEMORY MAP  
As shown in Figure 5, the MCU is capable of ad-  
dressing 64 Kbytes of memories and I/O registers.  
space includes up to 64 bytes for the stack from  
0140h to 017Fh.  
The available memory locations consist of 128  
bytes of register locations, 256 bytes of RAM and  
8 Kbytes of user program memory. The RAM  
The highest address bytes contain the user reset  
and interrupt vectors.  
Figure 5. Memory Map  
0080h  
0000h  
HW Registers  
Short Addressing  
(see Table 3)  
007Fh  
RAM  
0080h  
“Zero page”  
(128 bytes)  
256 bytes RAM  
017Fh  
00FFh  
0100h  
0180h  
16-bit Addressing  
Reserved  
DFFFh  
E000h  
Program Memory  
(8 Kbytes)  
FFDFh  
RAM  
(64 bytes)  
013Fh  
0140h  
Stack or  
16-bit Addressing  
RAM  
FFE0h  
Interrupt & Reset Vectors  
(64 bytes)  
017Fh  
(see Table 2)  
FFFFh  
Table 2. Interrupt Vector Map  
Vector Address  
Description  
Remarks  
FFE0-FFE1h  
FFE2-FFE3h  
FFE4-FFE5h  
FFE6-FFE7h  
FFE8-FFE9h  
FFEA-FFEBh  
FFEC-FFEDh  
FFEE-FFEFh  
FFF0-FFF1h  
FFF2-FFF3h  
FFF4-FFF5h  
FFF6-FFF7h  
FFF8-FFF9h  
FFFA-FFFBh  
FFFC-FFFDh  
FFFE-FFFFh  
Not used  
Not used  
Not used  
Not used  
Not used  
TIMER B interrupt vector  
TIMER A interrupt vector  
SPI interrupt vector  
Motor control interrupt vector (events: E, O)  
Motor control interrupt vector (events: C, D)  
Motor control interrupt vector (events: R, Z)  
External interrupt vector EI1: port B7..0  
External interrupt vector EI0: port A7..0  
Not used  
Internal Interrupt  
External Interrupt  
External Interrupt  
TRAP (software) interrupt vector  
RESET vector  
CPU Interrupt  
10/131  
ST72141K2-Auto  
Table 3. Hardware Register Map  
Register  
Reset  
Status  
Address  
Block  
Register Name  
Port A Data Register  
Port A Data Direction Register  
Port A Option Register  
Remarks  
R/W  
R/W  
R/W  
Label  
0000h  
0001h  
0002h  
PADR  
PADDR  
PAOR  
00h  
00h  
00h  
Port A  
0003h  
Reserved Area (1 byte)  
0004h  
0005h  
0006h  
PBDR  
PBDDR  
PBOR  
Port B Data Register  
Port B Data Direction Register  
Port B Option Register  
00h  
00h  
00h  
R/W  
R/W  
R/W  
Port B  
0007h  
to  
001F  
Reserved Area (24 bytes)  
Miscellaneous Register  
0020h  
MISCR  
00h  
R/W  
0021h  
0022h  
0023h  
SPIDR  
SPICR  
SPISR  
SPI Data I/O Register  
SPI Control Register  
SPI Status Register  
xxh  
0xh  
00h  
R/W  
R/W  
Read Only  
SPI  
0024h  
0025h  
WDGCR  
WDGSR  
Watchdog Control Register  
Watchdog Status Register  
7Fh  
00h  
R/W  
R/W  
WATCHDOG  
0026h  
to  
Reserved Area (11 bytes)  
0030h  
0031h  
0032h  
0033h  
0034h  
0035h  
0036h  
0037h  
0038h  
0039h  
003Ah  
003Bh  
003Ch  
003Dh  
003Eh  
003Fh  
TACR2  
TACR1  
TASR  
TAIC1HR  
TAIC1LR  
TAOC1HR  
TAOC1LR  
TACHR  
Timer A Control Register 2  
Timer A Control Register 1  
Timer A 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  
00h  
00h  
xxh  
xxh  
xxh  
80h  
00h  
FFh  
FCh  
FFh  
FCh  
xxh  
xxh  
80h  
00h  
R/W  
R/W  
Read Only  
Read Only  
Read Only  
R/W  
R/W  
TIMER A  
Read Only  
Read Only  
Read Only  
Read Only  
Read Only  
Read Only  
R/W  
TACLR  
Timer A Counter Low Register  
TAACHR  
TAACLR  
TAIC2HR  
TAIC2LR  
TAOC2HR  
TAOC2LR  
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  
R/W  
0040h  
Reserved Area (1 byte)  
11/131  
ST72141K2-Auto  
Register  
Label  
Reset  
Status  
Address  
Block  
Register Name  
Remarks  
R/W  
0041h  
0042h  
0043h  
0044h  
0045h  
0046h  
0047h  
0048h  
0049h  
004Ah  
004Bh  
004Ch  
004Dh  
004Eh  
004Fh  
TBCR2  
TBCR1  
TBSR  
TBIC1HR  
TBIC1LR  
TBOC1HR  
TBOC1LR  
TBCHR  
Timer B Control Register 2  
Timer B Control Register 1  
Timer B 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  
00h  
00h  
xxh  
xxh  
xxh  
80h  
00h  
FFh  
FCh  
FFh  
FCh  
xxh  
xxh  
80h  
00h  
R/W  
Read Only  
Read Only  
Read Only  
R/W  
R/W  
TIMER B  
Read Only  
Read Only  
Read Only  
Read Only  
Read Only  
Read Only  
R/W  
TBCLR  
Timer B Counter Low Register  
TBACHR  
TBACLR  
TBIC2HR  
TBIC2LR  
TBOC2HR  
TBOC2LR  
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  
R/W  
0050h  
to  
Reserved Area (16 bytes)  
005Fh  
0060h  
0061h  
0062h  
0063h  
0064h  
0065h  
0066h  
0067h  
0068h  
0069h  
006Ah  
006Bh  
006Ch  
006Dh  
MTIM  
Timer Counter Register  
Zn-1 Capture Register  
Zn Capture Register  
00h  
00h  
00h  
00h  
00h  
00h  
00h  
00h  
00h  
00h  
00h  
00h  
00h  
00h  
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  
R/W  
MZPRV  
MZREG  
MCOMP  
MDREG  
MWGHT  
MPRSR  
MIMR  
C
Compare Register  
n+1  
D capture/Compare Register  
Weight Register  
Prescaler and Ratio Register  
Interrupt Mask Register  
Interrupt Status Register  
Control Register A  
MOTOR  
CONTROL  
MISR  
MCRA  
MCRB  
MPHST  
MPAR  
Control Register B  
Phase State Register  
Output Parity Register  
Output Polarity Register  
MPOL  
006Eh  
to  
Reserved Area (2 bytes)  
006Fh  
0070h  
0071h  
ADCDR  
ADCCSR  
Data Register  
Control/Status Register  
00h  
00h  
Read Only  
R/W  
ADC  
0072h  
to  
Reserved Area (14 bytes)  
007Fh  
12/131  
ST72141K2-Auto  
1.5 EPROM PROGRAM MEMORY  
The program memory of the OTP and EPROM de-  
vices can be programmed with EPROM program-  
ming tools available from STMicroelectronics.  
It is recommended that the EPROM devices be  
kept out of direct sunlight, since the UV content of  
sunlight can be sufficient to cause functional fail-  
ure. Extended exposure to room level fluorescent  
lighting may also cause erasure.  
EPROM Erasure  
EPROM devices are erased by exposure to high  
intensity UV light admitted through the transparent  
window. This exposure discharges the floating  
gate to its initial state through induced photo cur-  
rent.  
An opaque coating (paint, tape, label, etc.) should  
be placed over the package window if the product  
is to be operated under these lighting conditions.  
Covering the window also reduces I  
in power-  
DD  
saving modes due to photo-diode leakage cur-  
rents.  
13/131  
ST72141K2-Auto  
2 CENTRAL PROCESSING UNIT  
2.1 INTRODUCTION  
Accumulator (A)  
The Accumulator is an 8-bit general purpose reg-  
ister used to hold operands and the results of the  
arithmetic and logic calculations and to manipulate  
data.  
This CPU has a full 8-bit architecture and contains  
six internal registers allowing efficient 8-bit data  
manipulation.  
Index Registers (X and Y)  
2.2 MAIN FEATURES  
In indexed addressing modes, these 8-bit registers  
are used to create either effective addresses or  
temporary storage areas for data manipulation.  
(The Cross-Assembler generates a precede in-  
struction (PRE) to indicate that the following in-  
struction refers to the Y register.)  
63 basic instructions  
Fast 8-bit by 8-bit multiply  
17 main addressing modes  
Two 8-bit index registers  
16-bit stack pointer  
Low power modes  
Maskable hardware interrupts  
Non-maskable software interrupt  
The Y register is not affected by the interrupt auto-  
matic procedures (not pushed to and popped from  
the stack).  
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).  
2.3 CPU REGISTERS  
The six CPU registers shown in Figure 6 are not  
present in the memory mapping and are accessed  
by specific instructions.  
Figure 6. CPU Registers  
7
0
ACCUMULATOR  
RESET VALUE = XXh  
7
0
0
X INDEX REGISTER  
Y INDEX REGISTER  
RESET VALUE = XXh  
7
RESET VALUE = XXh  
PCL  
PCH  
7
8
15  
0
PROGRAM COUNTER  
RESET VALUE = RESET VECTOR @ FFFEh-FFFFh  
7
1
0
H I N Z C  
X 1 X X X  
1
1
1
1
CONDITION CODE REGISTER  
RESET VALUE =  
8
1
15  
7
0
STACK POINTER  
RESET VALUE = STACK HIGHER ADDRESS  
X = Undefined Value  
14/131  
ST72141K2-Auto  
CPU REGISTERS (Cont’d)  
CONDITION CODE REGISTER (CC)  
Read/Write  
because the I bit is set by hardware at the start of  
the routine and reset by the IRET instruction at the  
end of the routine. If the I bit is cleared by software  
in the interrupt routine, pending interrupts are  
serviced regardless of the priority level of the cur-  
rent interrupt routine.  
Reset Value: 111x1xxx  
7
0
1
1
1
H
I
N
Z
C
Bit 2 = N Negative  
The 8-bit Condition Code register contains the in-  
terrupt mask and four flags representative of the  
result of the instruction just executed. This register  
can also be handled by the PUSH and POP in-  
structions.  
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 is a copy of the 7th  
bit of the result.  
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).  
These bits can be individually tested and/or con-  
trolled by specific instructions.  
This bit is accessed by the JRMI and JRPL instruc-  
tions.  
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 instruction. It is reset by hardware during the  
same instructions.  
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.  
0: No half carry has occurred.  
1: A half carry has occurred.  
This bit is tested using the JRH or JRNH instruc-  
tion. The H bit is useful in BCD arithmetic subrou-  
tines.  
This bit is accessed by the JREQ and JRNE test  
instructions.  
Bit 3 = I Interrupt mask  
This bit is set by hardware when entering in inter-  
rupt or by software to disable all interrupts except  
the TRAP software interrupt. This bit is cleared by  
software.  
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.  
0: Interrupts are enabled.  
1: Interrupts are disabled.  
This bit is controlled by the RIM, SIM and IRET in-  
structions and is tested by the JRM and JRNM in-  
structions.  
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.  
Note: Interrupts requested while I is set are  
latched and can be processed when I is cleared.  
By default an interrupt routine is not interruptible  
15/131  
ST72141K2-Auto  
CENTRAL PROCESSING UNIT (Cont’d)  
Stack Pointer (SP)  
The least significant byte of the Stack Pointer  
(called S) can be directly accessed by a LD in-  
struction.  
Read/Write  
Reset Value: 01 7Fh  
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 under-  
flow.  
15  
8
1
0
7
0
0
0
0
0
0
0
0
The stack is used to save the return address dur-  
ing 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 7.  
SP6  
SP5  
SP4  
SP3  
SP2  
SP1  
SP0  
The Stack Pointer is a 16-bit register which is al-  
ways 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 7).  
– When an interrupt is received, the SP is decre-  
mented and the context is pushed on the stack.  
Since the stack is 128 bytes deep, the 9th most  
significant bits are forced by hardware. Following  
an MCU Reset, or after a Reset Stack Pointer in-  
struction (RSP), the Stack Pointer contains its re-  
set value (the SP6 to SP0 bits are set) which is the  
stack higher address.  
– On return from interrupt, the SP is incremented  
and the context is popped from the stack.  
A subroutine call occupies two locations and an in-  
terrupt five locations in the stack area.  
Figure 7. Stack Manipulation Example  
CALL  
Subroutine  
RET  
or RSP  
PUSH Y  
POP Y  
IRET  
Interrupt  
Event  
@ 0100h  
SP  
SP  
SP  
Y
CC  
A
CC  
A
CC  
A
X
X
X
PCH  
PCL  
PCH  
PCL  
PCH  
PCL  
PCH  
PCL  
PCH  
PCL  
PCH  
PCL  
SP  
SP  
PCH  
PCL  
PCH  
PCL  
SP  
@ 017Fh  
Stack Higher Address = 017Fh  
0100h  
Stack Lower Address =  
16/131  
ST72141K2-Auto  
3 SUPPLY, RESET AND CLOCK MANAGEMENT  
3.1 INTRODUCTION  
The ST72141K2-Auto includes a range of utility  
features for securing the application in critical situ-  
ations (for example in case of a power brown-out),  
and reducing the number of external components.  
An overview is shown in Figure 8.  
3.2 Main Features  
Main supply low voltage detection (LVD)  
RESET Manager  
Low consumption resonator oscillator  
Main clock controller (MCC)  
Figure 8. Clock, RESET, Option and Supply Management Overview  
fMOTOR_CONTROL  
fSPI  
MAIN CLOCK  
OSC2  
OSC1  
fOSC  
OSCILLATOR  
CONTROLLER  
(MCC)  
fCPU  
FROM  
WATCHDOG  
PERIPHERAL  
RESET  
RESET  
LOW VOLTAGE  
DETECTOR  
(LVD)  
VDD  
VSS  
17/131  
ST72141K2-Auto  
3.3 LOW VOLTAGE DETECTOR (LVD)  
To allow the integration of power management  
features in the application, the Low Voltage Detec-  
tor function (LVD) generates a static reset when  
Provided the minimum V value (guaranteed for  
DD  
the oscillator frequency) is below V  
can only be in two modes:  
, the MCU  
LVDf  
the V supply voltage is below a V  
reference  
DD  
LVDf  
– under full software control  
– in static safe reset  
value. This means that it secures the power-up as  
well as the power-down keeping the ST7 in reset.  
In these conditions, secure operation is always en-  
sured for the application without the need for ex-  
ternal reset hardware.  
The V  
reference value for a voltage drop is  
LVDf  
lower than the V  
reference value for power-on  
LVDr  
in order to avoid a parasitic reset when the MCU  
starts running and sinks current on the supply  
(hysteresis).  
During a Low Voltage Detector Reset, the RESET  
pin is held low, thus permitting the MCU to reset  
other devices.  
The LVD Reset circuitry generates a reset when  
V
is below:  
DD  
– V  
– V  
when V is rising  
DD  
Note:  
LVDr  
when V is falling  
The LVD allows the device to be used without any  
external RESET circuitry.  
LVDf  
DD  
The LVD function is illustrated in Figure 9.  
Figure 9. Low Voltage Detector vs Reset  
V
DD  
HYSTERISIS  
V
LVDhyst  
V
V
LVDr  
LVDf  
RESET  
18/131  
ST72141K2-Auto  
3.4 RESET MANAGER  
The RESET block includes three RESET sources  
as shown in Figure 10:  
The RESET service routine vector is fixed at ad-  
dresses FFFEh-FFFFh in the ST7 memory map.  
– External RESET source pulse  
A 4096 CPU clock cycle delay allows the oscillator  
to stabilize and ensures that recovery has taken  
place from the Reset state.  
– Internal LVD RESET (Low Voltage Detection)  
– Internal WATCHDOG RESET  
The RESET vector fetch phase duration is 2 clock  
cycles.  
Figure 10. Reset Block Diagram  
INTERNAL  
RESET  
VDD  
fCPU  
RON  
RESET  
WATCHDOG RESET  
LVD RESET  
19/131  
ST72141K2-Auto  
RESET MANAGER (Cont’d)  
External RESET pin  
Generic Power-on RESET  
The RESET pin is both an input and an open-drain  
The function of the POR circuit consists of waking  
up the MCU by detecting (at around 2V) a dynamic  
output with integrated R  
weak pull-up resistor  
ON  
(see Figure 10). This pull-up has no fixed value but  
varies in accordance with the input voltage. It can  
be pulled low by external circuitry to reset the de-  
vice.  
(rising edge) variation of the V supply. At the be-  
DD  
ginning of this sequence, the MCU is configured in  
the RESET state. When the power supply voltage  
rises to a sufficient level, the oscillator starts to op-  
erate, whereupon an internal 4096 CPU cycles de-  
lay is initiated, in order to allow the oscillator to ful-  
ly stabilize before executing the first instruction.  
The initialization sequence is executed immediate-  
ly following the internal delay.  
A RESET signal originating from an external  
source must have a duration of at least t  
in  
PULSE  
order to be recognized. Two RESET sequences  
can be associated with this RESET source as  
shown in Figure 11.  
To ensure correct start-up, the user should take  
When the RESET is generated by an internal  
source, during the two first phases of the RESET  
sequence, the device RESET pin acts as an out-  
put that is pulled low.  
care that the V supply is stabilized at a sufficient  
DD  
level for the chosen frequency (see Section 10  
ELECTRICAL CHARACTERISTICS) before the  
reset signal is released. In addition, supply rising  
must start from 0V.  
As a consequence, the POR does not allow to su-  
pervise static, slowly rising, or falling, or noisy (os-  
cillating) V supplies.  
DD  
An external RC network connected to the RESET  
pin, or the LVD reset can be used instead to get  
the best performance.  
Figure 11. External RESET Sequences  
V
DD  
V
V
DD nominal  
LVDf  
RESET  
RUN  
RUN  
INTERNAL RESET  
4096 CLOCK CYCLES  
FETCH  
VECTOR  
DELAY  
t
PULSE  
EXTERNAL RESET SOURCE  
RESET PIN  
WATCHDOG RESET  
20/131  
ST72141K2-Auto  
RESET MANAGER (Cont’d)  
Internal Low Voltage Detection RESET (option)  
In the second sequence, a “delay” phase is used  
to keep the device in RESET state until V rises  
DD  
Two different RESET sequences caused by the in-  
ternal LVD circuitry can be distinguished:  
up to V  
(see Figure 12).  
LVDr  
- LVD Power-on RESET  
- Voltage Drop RESET  
Figure 12. LVD RESET Sequences  
V
DD  
V
V
DDnominal  
LVDr  
RESET  
POWER-  
OFF  
RUN  
INTERNAL RESET  
4096 CLOCK CYCLES VECTOR  
FETCH  
EXTERNAL RESET SOURCE  
RESET PIN  
WATCHDOG RESET  
V
DD  
V
V
V
DDnominal  
LVDr  
LVDf  
RESET  
RUN  
RUN  
INTERNAL RESET  
4096 CLOCK CYCLES VECTOR  
FETCH  
DELAY  
EXTERNAL RESET SOURCE  
RESET PIN  
WATCHDOG RESET  
21/131  
ST72141K2-Auto  
RESET MANAGER (Cont’d)  
Internal Watchdog RESET  
The RESET sequence generated by an internal  
Watchdog counter overflow has the shortest reset  
phase (see Figure 13).  
Figure 13. Watchdog RESET Sequence  
V
DD  
V
DDnominal  
V
LVDf  
RESET  
RUN  
RUN  
INTERNAL RESET  
FETCH  
4096 CLOCK CYCLES  
VECTOR  
EXTERNAL RESET SOURCE  
t
WDGRST  
RESET PIN  
WATCHDOG RESET  
WATCHDOG UNDERFLOW  
22/131  
ST72141K2-Auto  
3.5 LOW CONSUMPTION OSCILLATOR  
Crystal/Ceramic Oscillators  
This oscillator (based on constant current source)  
is optimized in terms of consumption and has the  
advantage of producing a very accurate rate on  
the main clock of the ST7.  
The main clock of the ST7 can be generated by  
two different sources:  
– an external source  
– a crystal or ceramic resonator oscillators  
When using this oscillator, the resonator and the  
load capacitances have to be connected as shown  
in Figure 15 and have to be mounted as close as  
possible to the oscillator pins in order to minimize  
output distortion and start-up stabilization time.  
External Clock Source  
In this mode, a square clock signal with ~50% duty  
cycle has to drive the OSC2 pin while the OSC1  
pin is tied to V (see Figure 14).  
SS  
This oscillator is not stopped during the RESET  
phase to avoid losing time in the oscillator start-up  
phase.  
Figure 15. Crystal/Ceramic Resonator  
Figure 14. External Clock  
ST7  
ST7  
OSC1  
OSC2  
OSC1  
OSC2  
EXTERNAL  
SOURCE  
C
C
L1  
L0  
LOAD  
CAPACITANCES  
23/131  
ST72141K2-Auto  
3.6 MAIN CLOCK CONTROLLER (MCC)  
The MCC block supplies the clock for the ST7  
CPU and its internal peripherals. It allows the  
SLOW power saving mode and the Motor Control  
and SPI peripheral clocks to be managed inde-  
pendently. The MCC functionality is controlled by  
two bits of the MISCR register: SMS and XT16.  
The XT16 bit acts on the clock of the motor control  
and SPI peripherals while the SMS bit acts on the  
CPU and the other peripherals.  
Figure 16. Main Clock Controller (MCC) Block Diagram  
OSC2  
OSCILLATOR  
OSC1  
MCC  
f
DIV 2  
DIV 16  
OSC  
f
CPU CLOCK  
TO CPU AND  
PERIPHERALS  
CPU  
MISCR  
XT16  
DIV 2  
-
-
-
-
-
-
SMS  
4MHz  
MOTOR CONTROL  
PERIPHERAL  
DIV 2  
4MHz  
SPI  
PERIPHERAL  
24/131  
ST72141K2-Auto  
4 INTERRUPTS  
4.1 INTRODUCTION  
4.2 NON-MASKABLE SOFTWARE INTERRUPT  
The ST7 core may be interrupted by one of two dif-  
ferent methods: maskable hardware interrupts as  
listed in Table 4 Interrupt Mapping on page 26 and  
a non-maskable software interrupt (TRAP). The  
Interrupt processing flowchart is shown in Figure  
17.  
This interrupt is entered when the TRAP instruc-  
tion is executed regardless of the state of the I bit.  
It will be serviced according to the flowchart in Fig-  
ure 17.  
4.3 EXTERNAL INTERRUPTS  
The maskable interrupts must be enabled by  
clearing the I bit in order to be serviced. However,  
disabled interrupts may be latched and processed  
when they are enabled (see Section 4.3 EXTER-  
NAL INTERRUPTS).  
External interrupt vectors can be loaded into the  
PC register if the corresponding external interrupt  
occurred and if the I bit is cleared. These interrupts  
allow the processor to leave the Halt low power  
mode.  
Note: After reset, all interrupts are disabled.  
The external interrupt polarity is selected through  
the miscellaneous register or interrupt register (if  
available).  
When an interrupt has to be serviced:  
– Normal processing is suspended at the end of  
the current instruction execution.  
An external interrupt triggered on edge will be  
latched and the interrupt request automatically  
cleared upon entering the interrupt service routine.  
– The PC, X, A and CC registers are saved onto  
the stack.  
If several input pins, connected to the same inter-  
rupt vector, are configured as interrupts, their sig-  
nals are logically NANDed before entering the  
edge/level detection block.  
– The I bit of the CC register is set to prevent addi-  
tional interrupts.  
– 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  
Table 4 Interrupt Mapping on page 26 for vector  
addresses).  
Caution: The type of sensitivity defined in the Mis-  
cellaneous or Interrupt register (if available) ap-  
plies to the ei source. In case of a NANDed source  
(as described on the I/O ports section), a low level  
on an I/O pin configured as input with interrupt,  
masks the interrupt request even in case of rising-  
edge sensitivity.  
The interrupt service routine should finish 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 I bit will be cleared and the main program will  
resume.  
4.4 PERIPHERAL INTERRUPTS  
Different peripheral interrupt flags in the status  
register are able to cause an interrupt when they  
are active if both:  
Priority Management  
By default, a servicing interrupt cannot be inter-  
rupted because the I bit is set by hardware enter-  
ing in interrupt routine.  
– The I bit of the CC register is cleared.  
– The corresponding enable bit is set in the control  
register.  
In the case when several interrupts are simultane-  
ously pending, a hardware priority defines which  
one will be serviced first (see Table 4 Interrupt  
Mapping on page 26).  
If any of these two conditions is false, the interrupt  
is latched and thus remains pending.  
Interrupts and Low Power Mode  
Clearing an interrupt request is done by:  
All interrupts allow the processor to leave the  
WAIT low power mode. Only external and specifi-  
cally mentioned interrupts allow the processor to  
leave the HALT low power mode (refer to the “Exit  
from HALT” column in Table 4 Interrupt Mapping  
on page 26).  
– Writing “0” to the corresponding bit in the status  
register or  
– Access to the status register while the flag is set  
followed by a read or write of an associated reg-  
ister.  
Note: The clearing sequence resets the internal  
latch. A pending interrupt (that is, waiting to be en-  
abled) will therefore be lost if the clear sequence is  
executed.  
25/131  
ST72141K2-Auto  
INTERRUPTS (Cont’d)  
Figure 17. Interrupt Processing Flowchart  
FROM RESET  
N
I BIT SET?  
Y
N
INTERRUPT  
PENDING?  
Y
FETCH NEXT INSTRUCTION  
N
IRET?  
STACK PC, X, A, CC  
SET I BIT  
Y
LOAD PC FROM INTERRUPT VECTOR  
EXECUTE INSTRUCTION  
RESTORE PC, X, A, CC FROM STACK  
THIS CLEARS I BIT BY DEFAULT  
Table 4. Interrupt Mapping  
Exit  
from  
HALT  
Source  
Block  
Register Priority  
Address  
Vector  
No.  
Description  
Label  
Order  
RESET  
TRAP  
Reset  
yes  
no  
FFFEh-FFFFh  
FFFCh-FFFDh  
FFFAh-FFFBh  
FFFAh-FFFBh  
FFF8h-FFF9h  
FFF4h-FFF5h  
FFF2h-FFF3h  
FFF0h-FFF1h  
FFEEh-FFEFh  
FFECh-FFEDh  
FFEAh-FFEBh  
FFE8h-FFE9h  
FFE6h-FFE7h  
FFE4h-FFE5h  
FFE2h-FFE3h  
FFE0h-FFE1h  
Highest  
Priority  
N/A  
Software Interrupt  
0
1
Not used  
EI0  
EI1  
External Interrupt Port A7..0 (C5..0*)  
External Interrupt Port B7..0 (C5..0*)  
Motor Control Interrupt (events: R, Z)  
Motor Control Interrupt (events: C, D)  
Motor Control Interrupt (events: E, O)  
SPI Peripheral Interrupts  
TIMER A Peripheral Interrupts  
TIMER B Peripheral Interrupts  
Not used  
yes  
yes  
no  
N/A  
2
3
4
MTC  
MISR  
no  
5
no  
6
SPI  
SPISR  
TASR  
TBSR  
no  
7
TIMER A  
TIMER B  
no  
8
no  
9
10  
11  
12  
13  
Not used  
Not used  
Not Used  
Lowest  
Priority  
Not Used  
26/131  
ST72141K2-Auto  
5 POWER SAVING MODES  
5.1 INTRODUCTION  
To give a large measure of flexibility to the applica-  
tion in terms of power consumption, three main  
power saving modes are implemented in the ST7  
(see Figure 18).  
After a RESET the normal operating mode is se-  
lected by default (RUN mode). This mode drives  
the device (CPU and embedded peripherals) by  
means of a master clock which is based on the  
main oscillator frequency divided by 2 (f  
).  
CPU  
From Run mode, the different power saving  
modes may be selected by setting the relevant  
register bits or by calling the specific ST7 software  
instruction whose action depends on the oscillator  
status.  
Figure 18. Power saving mode consumption / transitions  
HALT  
SLOW WAIT  
WAIT  
SLOW  
RUN  
High  
Low  
POWER CONSUMPTION  
27/131  
ST72141K2-Auto  
POWER SAVING MODES (Cont’d)  
5.2 HALT MODE  
When entering HALT mode, the I bit in the CC  
Register is forced to 0 to enable interrupts.  
The HALT mode is the lowest power consumption  
mode of the MCU. It is entered by executing the  
ST7 “HALT” instruction (see Figure 20).  
In the HALT mode the main oscillator is turned off  
causing all internal processing to be stopped, in-  
cluding the operation of the on-chip peripherals.  
All peripherals are not clocked except the ones  
which get their clock supply from another clock  
generator (such as an external or auxiliary oscilla-  
tor).  
The MCU can exit HALT mode on reception of ei-  
ther an external interrupt or a reset (see Table 2).  
When exiting HALT mode by means of a RESET  
or an interrupt, the oscillator is immediately turned  
on and the 4096 CPU cycle delay is used to stabi-  
lize the oscillator. After the start up delay, the CPU  
resumes operation by servicing the interrupt or by  
fetching the reset vector which woke it up (see Fig-  
ure 19).  
Figure 19. HALT Mode Timing Overview  
4096 CPU CYCLE  
RUN  
HALT  
RUN  
DELAY  
FETCH  
VECTOR  
RESET  
OR  
INTERRUPT  
HALT  
INSTRUCTION  
Figure 20. HALT Mode Flowchart  
HALT INSTRUCTION  
N
Y
WATCHDOG  
ENABLE  
HALT  
OSCILLATOR  
PERIPHERALS  
CPU  
OFF  
OFF  
OFF  
0
I BIT  
N
4096 clock cycles delay  
RESET  
Y
N
EXTERNAL*  
INTERRUPT  
OSCILLATOR  
PERIPHERALS  
CPU  
ON  
ON  
ON  
OSCILLATOR  
PERIPHERALS  
CPU  
ON  
OFF  
OFF  
FETCH RESET VECTOR  
OR SERVICE INTERRUPT**  
Y
Notes:  
External interrupt or internal interrupts with Exit from Halt Mode capability  
Before servicing an interrupt, the CC register is pushed on the stack.  
*
**  
28/131  
ST72141K2-Auto  
POWER SAVING MODES (Cont’d)  
5.3 WAIT MODE  
5.4 SLOW MODE  
WAIT mode places the MCU in a low power con-  
sumption mode by stopping the CPU.  
This mode has two targets:  
– To reduce power consumption by decreasing the  
internal clock in the device,  
This power saving mode is selected by calling the  
“WFI” ST7 software instruction.  
– To adapt the internal clock frequency (f  
the available supply voltage.  
) to  
CPU  
All peripherals remain active. During WAIT mode,  
the I bit of the CC register is forced to 0, to enable  
all interrupts. All other registers and memory re-  
main unchanged. The MCU remains in WAIT  
mode until an interrupt or Reset occurs, whereup-  
on the Program Counter branches to the starting  
address of the interrupt or Reset service routine.  
The MCU will remain in WAIT mode until a Reset  
or an Interrupt occurs, causing it to wake up.  
SLOW mode is controlled by the SMS bit in the  
MISCR register. This bit enables or disables Slow  
mode selecting the internal slow frequency (f  
).  
CPU  
In this mode, the oscillator frequency can be divid-  
ed by 32 instead of 2 in normal operating mode.  
The CPU and peripherals are clocked at this lower  
frequency except the Motor Control and the SPI  
peripherals which have their own clock selection  
bit (XT16) in the MISCR register.  
Refer to Figure 21.  
Figure 21. WAIT Mode Flowchart  
OSCILLATOR  
PERIPHERALS  
CPU  
I BIT  
ON  
ON  
OFF  
0
WFI INSTRUCTION  
N
RESET  
If exit is caused by a RESET, a 4096 CPU  
clock cycle delay is inserted.  
Y
N
INTERRUPT  
Y
OSCILLATOR  
PERIPHERALS  
CPU  
ON  
ON  
ON  
OSCILLATOR  
PERIPHERALS  
CPU  
ON  
OFF*  
OFF  
FETCH RESET VECTOR  
OR SERVICE INTERRUPT**  
Note:  
The peripheral clock is stopped only when exit caused by RESET and not by an interrupt.  
Before servicing an interrupt, the CC register is pushed on the stack.  
*
**  
29/131  
ST72141K2-Auto  
6 I/O PORTS  
6.1 INTRODUCTION  
programmable using the sensitivity bits in the Mis-  
cellaneous register.  
The I/O ports offer different functional modes:  
– transfer of data through digital inputs and outputs  
Each external interrupt vector is linked to a dedi-  
cated group of I/O port pins (see pinout description  
and interrupt section). If several input pins are se-  
lected simultaneously as interrupt source, these  
are logically NANDed. For this reason if one of the  
interrupt pins is tied low, it masks the other ones.  
and for specific pins:  
– external interrupt generation  
– alternate signal input/output for the on-chip pe-  
ripherals.  
An I/O port contains up to 8 pins. Each pin can be  
programmed independently as digital input (with or  
without interrupt generation) or digital output.  
In case of a floating input with interrupt configura-  
tion, special care must be taken when changing  
the configuration (see Figure 23).  
The external interrupts are hardware interrupts,  
which means that the request latch (not accessible  
directly by the application) is automatically cleared  
when the corresponding interrupt vector is  
fetched. To clear an unwanted pending interrupt  
by software, the sensitivity bits in the Miscellane-  
ous register must be modified.  
6.2 FUNCTIONAL DESCRIPTION  
Each port has two main registers:  
– Data Register (DR)  
– Data Direction Register (DDR)  
and one optional register:  
– Option Register (OR)  
6.2.2 Output Modes  
The output configuration is selected by setting the  
corresponding DDR register bit. In this case, writ-  
ing the DR register applies this digital value to the  
I/O pin through the latch. Then reading the DR reg-  
ister returns the previously stored value.  
Each I/O pin may be programmed using the corre-  
sponding register bits in the DDR and OR regis-  
ters: bit X corresponding to pin X of the port. The  
same correspondence is used for the DR register.  
The following description takes into account the  
OR register, (for specific ports which do not pro-  
vide this register refer to Section 6.3 I/O PORT IM-  
PLEMENTATION). The generic I/O block diagram  
is shown in Figure 22.  
Two different output modes can be selected by  
software through the OR register: Output push-pull  
and open-drain.  
DR register value and output pin status:  
6.2.1 Input Modes  
DR  
0
Push-pull  
Open-drain  
V
V
The input configuration is selected by clearing the  
corresponding DDR register bit.  
SS  
SS  
1
V
Floating  
DD  
In this case, reading the DR register returns the  
digital value applied to the external I/O pin.  
6.2.3 Alternate Functions  
When an on-chip peripheral is configured to use a  
pin, the alternate function is automatically select-  
ed. This alternate function takes priority over the  
standard I/O programming.  
Different input modes can be selected by software  
through the OR register.  
Notes:  
1. Writing the DR register modifies the latch value  
but does not affect the pin status.  
When the signal is coming from an on-chip periph-  
eral, the I/O pin is automatically configured in out-  
put mode (push-pull or open drain according to the  
peripheral).  
2. When switching from input to output mode, the  
DR register has to be written first to drive the cor-  
rect level on the pin as soon as the port is config-  
ured as an output.  
When the signal is going to an on-chip peripheral,  
the I/O pin must be configured in input mode. In  
this case, the pin state is also digitally readable by  
addressing the DR register.  
3. Do not use read/modify/write instructions (BSET  
or BRES) to modify the DR register.  
External interrupt function  
When an I/O is configured as Input with Interrupt,  
an event on this I/O can generate an external inter-  
rupt request to the CPU.  
Note: Input pull-up configuration can cause unex-  
pected value at the input of the alternate peripheral  
input. When an on-chip peripheral use a pin as in-  
put and output, this pin has to be configured in in-  
put floating mode.  
Each pin can independently generate an interrupt  
request. The interrupt sensitivity is independently  
30/131  
ST72141K2-Auto  
I/O PORTS (Cont’d)  
Figure 22. I/O Port General Block Diagram  
ALTERNATE  
OUTPUT  
1
0
REGISTER  
ACCESS  
P-BUFFER  
(see table below)  
V
DD  
ALTERNATE  
ENABLE  
PULL-UP  
(see table below)  
DR  
DDR  
OR  
V
DD  
PULL-UP  
CONFIGURATION  
PAD  
If implemented  
OR SEL  
DDR SEL  
DR SEL  
N-BUFFER  
DIODES  
(see table below)  
ANALOG  
INPUT  
CMOS  
SCHMITT  
TRIGGER  
1
0
ALTERNATE  
INPUT  
EXTERNAL  
INTERRUPT  
SOURCE (ei )  
FROM  
OTHER  
BITS  
x
POLARITY  
SELECTION  
Table 5. I/O Port Mode Options  
Configuration Mode  
Diodes  
Pull-Up  
P-Buffer  
to V  
to V  
SS  
DD  
Floating with/without Interrupt  
Pull-up with/without Interrupt  
Push-pull  
Off  
On  
Input  
Off  
On  
On  
Off  
On  
Off  
NI  
Output  
Open Drain (logic level)  
True Open Drain  
NI  
NI (see note)  
Legend: NI - not implemented  
Off - implemented not activated  
On - implemented and activated  
Note: The diode to V is not implemented in the  
DD  
true open drain pads. A local protection between  
the pad and V is implemented to protect the de-  
SS  
vice against positive stress.  
31/131  
ST72141K2-Auto  
I/O PORTS (Cont’d)  
Table 6. I/O Port Configurations  
Hardware Configuration  
DR REGISTER ACCESS  
NOT IMPLEMENTED IN  
TRUE OPEN DRAIN  
I/O PORTS  
V
DD  
PULL-UP  
CONFIGURATION  
R
W
R
PU  
DR  
REGISTER  
DATA BUS  
PAD  
ALTERNATE INPUT  
FROM  
OTHER  
PINS  
EXTERNAL INTERRUPT  
SOURCE (ei )  
x
INTERRUPT  
CONFIGURATION  
POLARITY  
SELECTION  
ANALOG INPUT  
NOT IMPLEMENTED IN  
TRUE OPEN DRAIN  
I/O PORTS  
DR REGISTER ACCESS  
V
DD  
R
PU  
R/W  
DR  
REGISTER  
DATA BUS  
PAD  
ALTERNATE  
ENABLE  
ALTERNATE  
OUTPUT  
NOT IMPLEMENTED IN  
TRUE OPEN DRAIN  
I/O PORTS  
DR REGISTER ACCESS  
V
DD  
R
PU  
R/W  
DR  
REGISTER  
DATA BUS  
PAD  
ALTERNATE  
ENABLE  
ALTERNATE  
OUTPUT  
Notes:  
1. When the I/O port is in input configuration and the associated alternate function is enabled as an output, reading the  
DR register will read the alternate function output status.  
2. When the I/O port is in output configuration and the associated alternate function is enabled as an input, the alternate  
function reads the pin status given by the DR register content.  
32/131  
ST72141K2-Auto  
I/O PORTS (Cont’d)  
CAUTION: The alternate function must not be ac-  
tivated as long as the pin is configured as input  
with interrupt, in order to avoid generating spurious  
interrupts.  
and specific feature of the I/O port such as ADC In-  
put or true open drain.  
Switching these I/O ports from one state to anoth-  
er should be done in a sequence that prevents un-  
wanted side effects. Recommended safe transi-  
tions are illustrated in Figure 23. Other transitions  
are potentially risky and should be avoided, since  
they are likely to present unwanted side-effects  
such as spurious interrupt generation.  
Analog alternate function  
When the pin is used as an ADC input, the I/O  
must be configured as floating input. The analog  
multiplexer (controlled by the ADC registers)  
switches the analog voltage present on the select-  
ed pin to the common analog rail which is connect-  
ed to the ADC input.  
Figure 23. Interrupt I/O Port State Transitions  
It is recommended not to change the voltage level  
or loading on any port pin while conversion is in  
progress. Furthermore it is recommended not to  
have clocking pins located close to a selected an-  
alog pin.  
01  
00  
10  
11  
INPUT  
INPUT  
OUTPUT  
open-drain  
OUTPUT  
push-pull  
floating/pull-up floating  
interrupt (reset state)  
WARNING: The analog input voltage level must  
be within the limits stated in the absolute maxi-  
mum ratings.  
= DDR, OR  
XX  
The I/O port register configurations are summa-  
rized as follows.  
6.3 I/O PORT IMPLEMENTATION  
The hardware implementation on each I/O port de-  
pends on the settings in the DDR and OR registers  
33/131  
ST72141K2-Auto  
I/O PORTS (Cont’d)  
Interrupt Ports  
PA7:0, PB5:3 (with pull-up)  
MODE  
DDR  
OR  
floating input  
0
0
1
1
0
1
0
1
pull-up interrupt input  
open drain output  
push-pull output  
True Open Drain Interrupt Ports  
PB2:0 (without pull-up)  
MODE  
DDR  
OR  
floating input  
0
0
1
0
1
floating interrupt input  
true open drain (high sink ports)  
X
Table 7. Port Configuration  
Input  
Output  
Port  
Pin name  
OR = 0  
OR = 1  
OR = 0  
OR = 1  
Port A  
Port B  
PA7:0  
PB5:3  
PB2:0  
floating  
floating  
floating  
pull-up interrupt  
pull-up interrupt  
open drain  
open drain  
push-pull  
push-pull  
floating interrupt  
true open drain  
34/131  
ST72141K2-Auto  
I/O PORTS (Cont’d)  
6.3.1 Register Description  
DATA REGISTER (DR)  
OPTION REGISTER (OR)  
Port x Data Register  
PxDR with x = A or B.  
Port x Option Register  
PxOR with x = A or B.  
Read/Write  
Read/Write  
Reset Value: 0000 0000 (00h)  
Reset Value: 0000 0000 (00h)  
7
0
7
0
D7  
D6  
D5  
D4  
D3  
D2  
D1  
D0  
O7  
O6  
O5  
O4  
O3  
O2  
O1  
O0  
Bit 7:0 = D[7:0] Data register 8 bits.  
Bit 7:0 = O[7:0] Option register 8 bits.  
The DR register has a specific behavior according  
to the selected input/output configuration. Writing  
the DR register is always taken into account even  
if the pin is configured as an input; this allows to al-  
ways have the expected level on the pin when tog-  
gling to output mode. Reading the DR register re-  
turns either the DR register latch content (pin con-  
figured as output) or the digital value applied to the  
I/O pin (pin configured as input).  
For specific I/O pins, this register is not implement-  
ed. In this case the DDR register is enough to se-  
lect the I/O pin configuration.  
The OR register allows to distinguish: in input  
mode if the pull-up with interrupt capability or the  
basic pull-up configuration is selected, in output  
mode if the push-pull or open drain configuration is  
selected.  
Each bit is set and cleared by software.  
Input mode:  
DATA DIRECTION REGISTER (DDR)  
Port x Data Direction Register  
PxDDR with x = A or B.  
0: Floating input  
1: Pull-up input with or without interrupt  
Output mode:  
0: Output open drain (with P-Buffer unactivated)  
1: Output push-pull (when available)  
Read/Write  
Reset Value: 0000 0000 (00h)  
7
0
DD7  
DD6  
DD5  
DD4  
DD3  
DD2  
DD1  
DD0  
Bit 7:0 = DD[7:0] Data direction register 8 bits.  
The DDR register gives the input/output direction  
configuration of the pins. Each bits is set and  
cleared by software.  
0: Input mode  
1: Output mode  
35/131  
ST72141K2-Auto  
I/O PORTS (Cont’d)  
Table 8. I/O Port Register Map and Reset Values  
Address (Hex.)  
Register Label  
7
0
6
0
5
0
4
0
3
0
2
0
1
0
0
0
Reset value of all I/O port registers  
0000h  
0001h  
0002h  
0004h  
0005h  
0006h  
PADR  
PADDR  
PAOR  
PBDR  
PBDDR  
PBOR  
MSB  
MSB  
LSB  
LSB  
36/131  
ST72141K2-Auto  
7 MISCELLANEOUS REGISTER  
7.1 INTRODUCTION  
7.3 I/O PORT ALTERNATE FUNCTIONS  
The miscellaneous register allows control over  
several different features such as the external in-  
terrupts or the I/O alternate functions.  
The MISCR register manages the SPI SS pin al-  
ternate function configuration. This makes it possi-  
ble to use the PB2 I/O port function while the SPI is  
active.  
These functions are described in detail in Section  
7.5 MISCELLANEOUS REGISTER DESCRIP-  
TION.  
7.2 I/O PORT INTERRUPT SENSITIVITY  
DESCRIPTION  
The external interrupt sensitivity is controlled by  
the ISxx bits of the Miscellaneous register. This  
control allows to have two fully independent exter-  
nal interrupt source sensitivities as shown in Fig-  
ure 24.  
7.4 CLOCK PRESCALER SELECTION  
The MISCR register is used to select the SLOW  
mode (see Section 5.4 SLOW MODE for more de-  
tails) and the SPI and Motor Control peripheral  
clock prescaler.  
Each external interrupt source can be generated  
on four different events on the pin:  
– Falling edge  
– Rising edge  
– Falling and rising edge  
– Falling edge and low level  
To guaranty correct functionality, a modification of  
the sensitivity in the MISCR register must be done  
only when the I bit of the CC register is set to 1 (in-  
terrupt masked). See I/O port register and Miscel-  
laneous register descriptions for more details on  
the programming.  
Figure 24. External Interrupt Sensitivity  
MISCR  
IS01  
IS00  
EI0  
PA7  
PA0  
INTERRUPT  
SOURCE  
SENSITIVITY  
CONTROL  
MISCR  
IS11  
IS10  
EI1  
PB7  
PB0  
INTERRUPT  
SOURCE  
SENSITIVITY  
CONTROL  
37/131  
ST72141K2-Auto  
MISCELLANEOUS REGISTER (Cont’d)  
7.5  
MISCELLANEOUS  
REGISTER  
DESCRIPTION  
Bits 4:3 = IS1[1:0] EI1 sensitivity  
The interrupt sensitivity defined using the IS1[1:0]  
bits combination is applied to the EI1 external in-  
terrupts. These two bits can be written only when  
the I bit of the CC register is set to 1 (interrupt  
masked).  
MISCELLANEOUS REGISTER (MISCR)  
Read/Write  
Reset Value: 0000 0000 (00h)  
EI1: Port B  
7
0
IS11 IS10  
External Interrupt Sensitivity  
Falling edge & low level  
Rising edge only  
XT16 SSM SSI IS11 IS10 IS01 IS00 SMS  
0
0
1
1
0
1
0
1
Bit 7 = XT16 MTC and SPI clock selection  
This bit is set and cleared by software. The maxi-  
mum allowed frequency is 4MHz.  
Falling edge only  
Rising and falling edge  
0: MTC and SPI clock supplied with f  
1: MTC and SPI clock supplied with f  
/2  
/4  
OSC  
OSC  
Bits 2:1 = IS0[1:0] EI0 sensitivity  
The interrupt sensitivity defined using the IS0[1:0]  
bits combination is applied to the EI1 external in-  
terrupts. These two bits can be written only when  
the I bit of the CC register is set to 1 (interrupt  
masked).  
Bit 6 = SSM SS mode selection  
This bit is set and cleared by software.  
0: Normal mode - the level of the SPI SS signal is  
the external SS pin.  
1: I/O mode, the level of the SPI SS signal is read  
from the SSI bit.  
EI0: Port A  
IS01 IS00  
External Interrupt Sensitivity  
Falling edge & low level  
Rising edge only  
Bit 5 = SSI SS internal mode  
0
0
1
1
0
1
0
1
This bit replaces the SS pin of the SPI when the  
SSM bit is set to 1. (see SPI description). It is set  
and cleared by software.  
Falling edge only  
Rising and falling edge  
Bit 0 = SMS Slow mode select  
This bit is set and cleared by software.  
0: Normal mode. f  
= fOSC / 2  
CPU  
1: Slow mode. f  
= fOSC / 32  
CPU  
See sections on low power consumption mode  
and MCC for more details.  
Table 9. Miscellaneous Register Map and Reset Values  
Address  
(Hex.)  
Register  
Label  
7
6
5
4
3
2
1
0
MISCR  
Reset Value  
XT16  
0
SSM  
0
SSI  
0
IS11  
0
IS10  
0
IS01  
0
IS00  
0
SMS  
0
0020h  
38/131  
ST72141K2-Auto  
8 ON-CHIP PERIPHERALS  
8.1 MOTOR CONTROLLER (MTC)  
8.1.1 Introduction  
– The output polarity is programmable channel  
by channel.  
The ST7 Motor Controller (MTC) can be seen as a  
Pulse Width Modulator multiplexed on six output  
channels, and a Back Electromotive Force  
(BEMF) zero-crossing detector for sensorless con-  
trol of Permanent Magnet Direct Current (PMDC)  
brushless motors.  
– An software enabled bit (active low) forces the  
outputs in HiZ.  
– An “emergency stop” input pin (active low)  
asynchronously forces the outputs in HiZ.  
Table 10. MTC Registers  
The MTC is particularly suited to driving synchro-  
nous motors and supports operating modes like:  
Register Description  
MTIM Timer Counter Register  
MZPRV Capture Z Register  
Page  
66  
66  
66  
66  
66  
66  
66  
67  
67  
68  
69  
70  
70  
70  
– Commutation step control with motor voltage  
regulation and current limitation  
n-1  
MZREG Capture Z Register  
n
– Commutation step control with motor current  
regulation, i.e. direct torque control  
MCOMP Compare C  
Register  
n+1  
MDREG Demagnetization Register  
– Sensor or sensorless motor phase commutation  
control  
MWGHT A Weight Register  
n
MPRSR Prescaler and Sampling Register  
– BEMF zero-crossing detection with high sensitiv-  
ity. The integrated phase voltage comparator is  
directly referred to the full BEMF voltage without  
any attenuation. A BEMF voltage down to  
200mV can be detected, providing high noise im-  
munity and self-commutated operation in a large  
speed range.  
MIMR  
MISR  
Interrupt Mask Register  
Interrupt Status Register  
Control Register A  
MCRA  
MCRB  
Control Register B  
MPHST Phase State Register  
MPAR  
MPOL  
Parity Register  
Polarity Register  
– Realtime motor winding demagnetization detec-  
tion for fine-tuning the phase voltage masking  
time to be applied before BEMF monitoring.  
8.1.3 Application Example  
– Automatic and programmable delay between  
BEMF zero-crossing detection and motor phase  
commutation.  
This example shows a six-step command se-  
quence for a 3-phase permanent magnet DC  
brushless motor (PMDC motor). Figure 26 shows  
the phase steps and voltage, while Table 11  
shows the relevant phase configurations.  
8.1.2 Main Features  
2 on-chip analog comparators, one for BEMF  
zero-crossing detection with 100mV hysteresis,  
the other for current regulation or limitation  
4 selectable reference voltages for the  
hysteresis comparator (0.2 V, 0.6 V, 1.2 V,  
2.5 V)  
To run this kind of motor efficiently, an autoswitch-  
ing mode has to be used, that is, the position of the  
rotor must self-generate the powered winding  
commutation. The BEMF zero crossing (Z event)  
on the non-excited winding is used by the MTC as  
a rotor position sensor. The delay between this  
event and the commutation is computed by the  
8-bit timer (MTIM) with two compare registers  
and two capture features  
MTC and the commutation event C is automati-  
n
Measurement window generator for BEMF  
cally generated after this delay.  
zero-crossing detection  
After the commutation occurs, the MTC waits until  
the winding is completely demagnetized by the  
free-wheeling diode: during this phase the winding  
is tied to 0V or to the HV high voltage rail and no  
BEMF can be read. At the end of this phase a new  
BEMF zero-crossing detection is enabled.  
Auto-calibrated prescaler with 16 division steps  
8x8-bit multiplier  
Phase input multiplexer  
Sophisticated output management:  
– The six output channels can be split into two  
The end of demagnetization event (D), is also de-  
tected by the MTC or simulated with a timer com-  
pare feature when no detection is possible.  
groups (odd and even).  
– The PWM signal can be multiplexed on even,  
odd or both groups, alternatively or simultane-  
ously.  
39/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
The MTC manages these three events always in  
the same order: Z generates C after a delay com-  
puted in realtime, then waits for D in order to ena-  
ble the peripheral to detect another Z event.  
All detections of Z events are done during a short  
n
measurement window while the high side switch is  
turned off. For this reason the PWM signal is ap-  
plied on the high side switches.  
The speed regulation is managed by the micro-  
controller, by means of an adjustable reference  
current level in case of current control, or by direct  
PWM duty-cycle adjustment in case of voltage  
control.  
When the high side switch is off, the high side  
winding is tied to 0V by the free-wheeling diode,  
the low side winding voltage is also held at 0V by  
the low side ON switch and the complete BEMF  
voltage is present on the third winding: detection is  
then possible.  
Figure 25. Chronogram of Events (in Autoswitched Mode)  
C event  
Z event  
D
event  
H
D event  
S
Cn processing  
Wait for C  
Wait for D  
n
n
Wait for Z  
Z > Z  
T
Z
n min  
C > C  
n
n min  
D
C
n
n
t
Voltage on phase A  
Voltage on phase B  
Voltage on phase C  
BEMF  
sampling  
P signal when sampled  
(Output of the  
V
DD  
analog MUX)  
V
REF  
V
(Threshold value for  
SS  
Input comparator)  
40/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Figure 26. Example of Command Sequence for 6-step Mode (typical 3-phase PMDC Motor Control)  
Σ
Σ
Σ
Σ
Σ
Σ
Σ
Σ
Σ
3
1
2
3
4
5
6
1
2
Step  
HV  
Switch  
0
1
2
3
4
T0  
T2  
T4  
B
I
I
6
1
I
4
I
3
I
A
5
2
C
I
5
Node  
HV  
HV/2  
0
A
B
C
T3  
T5  
T1  
HV  
HV/2  
0
HV  
HV/2  
0
Note: Control & sampling PWM influence is not represented on these simplified chronograms.  
Σ
Σ
Σ
Σ
Σ
Σ
5
6
1
2
3
4
HV  
C
2
C
4
D
2
HV/2  
Superimposed voltage  
(BEMF induced by rotor)  
- approx. HV/2 (PWM on)  
- approx. 0V (PWM off)  
0V  
Z
D
Z
5
5
2
t
PWM off pulses  
Demagnetization  
Commutation delay  
Wait for BEMF = 0  
41/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Table 11. Step Configuration Summary  
Step  
Configuration  
Σ
Σ
Σ
Σ
Σ
Σ
6
1
2
3
4
5
Current direction  
High side  
A to B  
T0  
A to C  
T0  
B to C  
T2  
B to A  
T2  
C to A  
T4  
C to B  
T4  
Low side  
T5  
T1  
T1  
T3  
T3  
T5  
OO[5:0] bits in MPHST register  
Measurement done on:  
IS[1:0] bits in MPHST register  
Back EMF shape  
100001  
MCIC  
10  
000011  
MCIB  
01  
000110  
MCIA  
00  
001100  
MCIC  
10  
011000  
MCIB  
01  
110000  
MCIA  
00  
Falling  
Rising  
Falling  
Rising  
Falling  
Rising  
CPB bit in MCRB register  
(ZVD bit = 0)  
0
1
0
1
0
1
Voltage on measured point at the  
start of demagnetization  
0V  
HV  
0V  
HV  
0V  
HV  
HDM-SDM bits in MCRB register  
10  
11  
10  
11  
10  
11  
PWM side selection to accelerate de-  
magnetization  
Odd Side Even Side Odd Side Even Side Odd Side Even Side  
Driver selection to accelerate de-  
magnetization  
T5  
T0  
T1  
T2  
T3  
T4  
For a detailed description of the MTC registers, see Section 8.1.7.  
42/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
8.1.4 Functional Description  
– The CHANNEL MANAGER with the PWM multi-  
plexer, polarity programming capability and  
emergency HiZ configuration input  
The MTC can be split into four main parts as  
shown in the simplified block diagram in Figure 27.  
8.1.4.1 Input Detection Block  
– The BEMF ZERO-CROSSING DETECTOR with  
a comparator and an input multiplexer  
This block can operate in sensor mode or sensor-  
less mode. The mode is selected via the SR bit in  
the MCRA register. The block diagram is shown in  
Figure 28.  
– The DELAY MANAGER with an 8-bit timer  
(MTIM) and an 8x8 bit multiplier  
– The PWM MANAGER, including a measurement  
window generator, a mode selector and a current  
comparator  
Figure 27. Simplified MTC Block Diagram  
BEMF ZERO-CROSSING  
DETECTOR  
DELAY MANAGER  
MCIA  
BEMF=0  
[Z]  
MCIB  
MCIC  
MTIM  
TIMER  
DELAY  
CAPTURE Zn  
WEIGHT  
Internal V  
REF  
=?  
DELAY = WEIGHT x Zn  
COMMUTE [C]  
MCO5  
MCO4  
MCO3  
MCO2  
MCO1  
MCO0  
MEASUREMENT  
WINDOW  
GENERATOR  
(I)  
CURRENT  
VOLTAGE  
(V)  
(I)  
(V)  
MODE  
NMCES  
MCCFI  
OCP1A  
(V)  
(I)  
1
PWM ( )  
V
DD  
C
ext  
PWM MANAGER  
CHANNEL MANAGER  
(I)  
R
1ext  
(V)  
Note 1: The PWM signal is generated by the ST7 16-bit Timer  
[Z] : Back EMF Zero-crossing event  
R
2ext  
Z : Time elapsed between two consecutive Z events  
n
[C] : Commutation event  
C : Time delayed after Z event to generate C event  
n
(I): Current mode  
(V): Voltage mode  
43/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Input Pins  
connected to each motor phase through a single  
resistor.  
The MCIA, MCIB and MCIC input pins can be  
used as analog pins in Sensorless mode or as dig-  
ital pins in Sensor mode. In sensorless mode, the  
analog inputs are used to measure the BEMF zero  
crossing and to detect the end of demagnetization  
if required. In Sensor mode, they are connected to  
sensor outputs.  
Note: In high voltage applications, in Sensorless  
mode and for certain motors and power topologies  
(with parasitic capacitance or other), it may be re-  
quired to add external pull-up Schottky 0.4 V (e.g.  
BAT48) diodes on the MCIA, MCIB and MCIC  
pins.  
A multiplexer, programmed by the IS[1:0] bits in  
MPHST register selects the input pins and con-  
nects them to the rotor position control logic in ei-  
ther Sensorless or Sensor mode.  
Due to the presence of diodes, these pins can per-  
manently support an input current of 5 mA. In Sen-  
sorless mode, this feature enables the inputs to be  
Figure 28. Input Stage  
Event Detection  
Input Comparator Block  
External Input Block  
MPHST Register  
IS[1:0]  
Input Sel Reg  
n
MCIA  
MCIB  
MCIC  
A
B
C
00  
C
P
01  
10  
+
Sample  
D
Q
-
CP  
V
REF  
D
S,H  
C
MCRB Register  
VR[1:0]  
Freq (T = 1.25µs) for demagnetization and sensors  
Sampling frequency  
I
* = Preload register,  
changes taken into  
16-bit Timer PWM  
V
account at next C event.  
MCRA Register  
V0C1 bit  
Notes:  
Reg  
Updated/Shifted on  
R
MCRB Register MPAR Register  
MPAR Register  
REO bit  
Updated with Reg  
on C  
n+1  
CPB bit*  
ZVD bit  
n
I
Current Mode  
D
C
S,H  
Voltage Mode  
20µs / D  
V
events:  
Commutation  
BEFM Zero-crossing  
or  
or  
or  
Z
C
Z
2
1
Sample  
D
S,H  
End Of Demagnetization  
Emergency Stop  
Ratio Updated (+1 or -1)  
Multiplier Overflow  
MCRA Register  
SR bit  
20µs / C  
E
+/-  
R
O
or  
1
Branch taken after C event  
Branch taken after D event  
D
H
2
CPB bit* HDM bit*  
n
n
MCRB Register  
44/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Sensorless Mode  
During a short period after a phase commutation  
(C event), the winding is no longer excited but  
needs a demagnetization phase during which the  
BEMF cannot be read. A demagnetization current  
goes through the free-wheeling diodes and the  
winding voltage is stuck at the high voltage or to  
the ground terminal. For this reason an “end of de-  
magnetization event” D must be detected on the  
winding before the detector can sense a BEMF  
zero crossing.  
This mode is used to detect BEMF zero crossing  
and end of demagnetization events.  
The analog phase multiplexer connects the non-  
excited motor winding to an analog 100mV hyster-  
esis comparator referred to a selectable reference  
voltage.  
The VR[1:0] bits in the MCRB register select the  
reference voltage from four internal values de-  
pending on the noise level and the application volt-  
age supply.  
For the end-of-demagnetization detection, no spe-  
cial PWM configuration is needed, the comparator  
sensing is done at a fixed 800 kHz sampling fre-  
quency.  
BEMF detections are performed during the meas-  
urement window, when the excited windings are  
free-wheeling through the low side switches and  
diodes. At this stage the common star connection  
So, the three events C (commutation), D (demag-  
netization) and Z (BEMF zero crossing) must al-  
ways occur in this order.  
voltage is near to ground voltage (instead of V /2  
DD  
when the excited windings are powered) and the  
complete BEMF voltage is present on the non-ex-  
cited winding terminal, referred to the ground ter-  
minal.  
The comparator output is processed by a detector  
that automatically recognizes the D or Z event, de-  
pending on the CPB or ZVD edge and level config-  
uration bits as described in Table 12.  
The zero crossing sampling frequency is then de-  
fined, in current mode, by the measurement win-  
dow generator frequency (SA[3:0] bits in the  
MPRSR register) or, in voltage mode, by the 16-bit  
Timer PWM frequency and duty cycle.  
A 20µs filter after a C event disables a D event if  
spurious spikes occur.  
Another 20µs filter after a D event disables a Z  
event if spurious spikes occur.  
Table 12. ZVD and CPB Edge Selection Bits  
ZVD bit  
CPB bit  
Event generation vs input data sampled  
20-µs filter 20-µs filter  
0
0
C
D
Z
H
20-µs filter 20-µs filter  
0
1
1
1
0
1
C
D
Z
H
20-µs filter 20-µs filter  
C
D
Z
Z
H
20-µs filter 20-µs filter  
C
D
H
Note: The ZVD bit is located in the MPAR register, the CPB bit is in the MCRB register.  
45/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Demagnetization (D) Event  
not precede a D event because the latter could  
H
be detected as a Z event.  
At the end of the demagnetization phase, current  
no longer goes through the free-wheeling diodes.  
The voltage on the non-excited winding terminal  
goes from one of the power rail voltages to the  
common star connection voltage plus the BEMF  
voltage. In some cases (if the BEMF voltage is  
positive and the free-wheeling diodes are at  
ground for example) this end of demagnetization  
can be seen as a voltage edge on the selected  
MCIx input and it is called a hardware demagneti-  
Software demagnetization can also be always  
used if the HDM bit is reset and the SDM bit is set.  
This mode works as a programmable masking  
time between the C and Z events. To drive the mo-  
tor securely, the masking time must be always  
greater than the real demagnetization time in order  
to avoid a spurious Z event.  
When an event occurs, (either D or D ) the DI bit  
H
S
in the MISR register is set and an interrupt request  
is generated if the DIM bit of register MIMR is set.  
zation event D . See Table 12.  
H
If enabled by the HDM bit in the MCRB register,  
the current value of the MTIM timer is captured in  
register MDREG when this event occurs in order  
to be able to simulate the demagnetization phase  
for the next steps.  
Warning 1: Due to the alternate automatic capture  
and compare of the MTIM timer with MDREG reg-  
ister by D and D events, the MDREG register  
H
S
should be manipulated with special care.  
Warning 2: To avoid a system stop, the value writ-  
ten to the MDREG register in Soft Demagnetiza-  
tion Mode (SDM = 1) should always be:  
– Greater than the MCOMP value of the commuta-  
tion before the related demagnetization  
When enabled by the SDM bit in the MCRB regis-  
ter, demagnetization can also be simulated by  
comparing the MTIM timer with the MDREG regis-  
ter. This kind of demagnetization is called software  
demagnetization D .  
S
– Greater than the value in the MTIM counter at  
that moment (when writing to the MDREG regis-  
ter).  
If the HDM and SDM bits are both set, the first  
event that occurs, triggers a demagnetization  
event. For this to work correctly, a D event must  
S
Figure 29. D Event Generation Mechanism  
§
MTIM [8-bit Up Counter]  
D
S,H  
C
8
D
H
To Z event detection  
MCRA Register  
2
1
Sample  
§
MDREG [D ]  
n
20 µs / C  
SR bit  
or  
Compare  
MCRB Register  
SDM bit  
D
H
CPB bit* HDM bit*  
n
n
MCRB Register  
D
S
D
D
S
H
D = D & HDM bit + D & SDM bit  
H
S
F(x)  
HDM bit  
SDM bit  
D
To interrupt generator  
§
Register updated on R event  
* = Preload register, changes taken into account at next C event  
46/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Table 13. Demagnetization (D) Event Generation (example for ZVD = 0)  
CPB bit = 1  
CPB bit = 0  
HDM  
bit  
Meaning  
(Even Σ)  
(Odd Σ)  
D = D = Output Compare [MDREG, MTIM registers]  
S
Undershoot due to  
Weak / null  
motor parasite or first  
sampling  
undershoot and  
BEMF positive  
Σ
Σ
2
2
Σ
5
HVV  
HV  
HVV  
D
C
S
C
Software Mode  
D
S
0
(SDM bit = 1 and  
HDM bit = 0)  
D
(*)  
S
C
HV/2  
HV/2  
HV/2  
(*)  
(*)  
0V  
0V  
0V  
Z
Z
Z
D = D  
D = D + D  
H
H
S
(Hardware detection only)  
(Hardware detection or Output compare true)  
Undershoot due to  
motor parasite or first  
Weak / null  
undershoot and  
sampling  
BEMF positive  
Σ
Σ
2
2
Σ
5
HV  
HV  
HV  
C
Hardware/Simulat-  
ed Mode  
D
S
C
1
D
(*)  
S
(SDM bit = 1 and  
HDM bit = 1)  
C
HV/2  
HV/2  
HV/2  
(*)  
(*)  
0V  
0V  
0V  
Z
D
D
H
Z
H
Z
(*) Note: This is a zoom to the additional voltage induced by the rotor (Back EMF)  
47/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
BEMF Zero Crossing (Z) Event  
Consequently, BEMF reading (that is, comparison  
with a voltage close to 0V) can only be done when  
the PWM is applied on the high side drivers.  
When both C and D events have occurred, the  
PWM may be switched to another group of outputs  
(depending on the OS[2:0] bits in the MCRB regis-  
ter) and the real BEMF zero crossing sampling can  
start (see Figure 31).  
For this reason the MTC outputs can be split in two  
groups called ODD and EVEN and the BEMF  
reading will be done only when PWM is applied on  
one of these two groups. The REO bit in the MPAR  
register is used to select the group to be used for  
BEMF sensing (high side group).  
A BEMF voltage is present on the non-powered  
terminal but referred to common star connection of  
the motor whose voltage is equal to V /2.  
DD  
Refer to Table 15 for an overview of when a BEMF  
can be read depending on REO bit, PWM mode  
and function mode of peripheral.  
When a winding is free-wheeling (during PWM off-  
time) its terminal voltage changes to the other  
power rail voltage, that means if the PWM is ap-  
plied on the high side driver, free-wheeling will be  
done through the high side diode and the terminal  
will be 0V.  
Depending on the edge and level selection (ZVD  
and CPB) bits and when PWM is applied on the  
correct group, a BEMF zero crossing detection  
sets the ZI bit in the MISR register and generates  
an interrupt if the ZIM bit is set.  
This is used to force the common star connection  
to 0V in order to read the BEMF referred to the  
ground terminal.  
The Z event also triggers some timer/multiplier op-  
erations; for more details see Section 8.1.4.2.  
Figure 30. Sampling and Zero Crossing Blocks  
Sample  
Output of hysteresis comparator  
D
Q
Freq. (T = 1.25µs) for Demagnetization and Sensor  
CP  
1
2
Sampling frequency  
I
16-bit Timer PWM  
V
DS,H  
MCRA Register  
Notes:  
C
V0C1 bit  
Updated/Shifted on  
R
Reg  
Reg  
MCRB Register  
MPAR Register  
ZVD bit  
Updated with Reg  
on C  
n+1  
MPAR Register  
REO bit  
n
CPB bit*  
n
I
Current Mode  
DS,H  
V
Voltage Mode  
20µs / D  
C
events:  
C
Z
or  
or  
or  
Commutation  
Z
BEFM  
Zero-crossing  
2
Sample  
D
S,H  
End Of  
Demagnetization  
E
Emergency Stop  
Ratio Updated (+1 or -1)  
SR bit  
+/-  
R
1
To D detection  
O
1
Multiplier  
Overflow  
MCRA Register  
Branch taken after C event  
Branch taken after D event  
2
* = Preload register, changes taken into account at next C event.  
48/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Sensor Mode  
The minimum off time for current control PWM is  
also reduced to 1.25µs.  
In sensor mode, the rotor position information is  
given to the peripheral by means of logical data on  
the three inputs MCIA, MCIB and MCIC.  
Procedure for reading sensor inputs in Direct  
Access mode: In Direct Access mode, the periph-  
eral clock is disabled as shown in Table 25. As the  
data present on the selected input is synchronized  
by an 800 kHz clock, the sensor cannot be read di-  
rectly (the value is latched). To read the sensor  
data the following steps have to be performed:  
For each step one of these three inputs is selected  
(IS[1:0] bits in register MPHST) in order to detect  
the Z event.  
In this case Demagnetization has no meaning and  
the relevant features such as the special PWM  
configuration, D or D management, or 20µs filter  
are not available (see Table 14).  
1. Select the appropriate MCIx input pin by means  
of the IS[1:0] bits in the MPHST register.  
S
H
2. Switch from direct access mode to indirect  
access mode in order to latch the sensor data  
(DAC bit in MCRA register).  
For this configuration the rotor detection does not  
need a particular phase configuration to validate  
the measurement and a Z event can be read from  
any detection window. A fixed sampling frequency  
(800 kHz) is used, that means the Z event and po-  
sition sensoring is more precise than it is in sen-  
sorless mode.  
3. Switch back to direct access mode.  
4. Read the comparator output (HST bit in the  
MIMR register).  
Table 14. Sensor mode selection  
Event detection  
Behavior of the output  
SR bit  
Mode  
OS2 bit use  
Filtering  
PWM  
sampling clock  
Sensors not  
used  
D: Clock 1.25µs  
Z: SA&OT config.  
20µs after C for D event  
20µs after D for Z event  
“Before D” behavior  
and “after D” behavior  
0
1
Enabled  
Sensors  
used  
Disabled  
Z: Clock 1.25µs  
20µs after C for Z event  
Only “after D” behavior  
49/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Figure 31. Functional Diagram of Z Detection after D Event  
D or D  
S
H
Begin  
20µs Filter turned on  
Switch Sampling Clock[D] -> Sampling Clock[Z]  
No  
Side change on  
Output PWM  
?
Yes  
Change the side according to OS[2:0]  
Wait for next sampling clock edge  
No  
Read enable  
by REO  
?
Yes  
No  
Filter  
off  
?
Yes  
Read enabled  
End  
50/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Table 15. Modes permitting BEMF reading after Demagnetization (D event)  
OS[2:0]  
bits  
REO bit  
SR bit  
V0C1 bit  
Significant  
PWM  
Group  
(Read  
BEMF on  
Even/Odd  
group)  
Demagnet-  
ization  
BEMF reading permitted after D event  
when:  
(Sensor/  
Sensor-  
less Mode)  
(Voltage/  
Current  
Mode)  
(PWM  
Output  
Config.)  
Sensorless mode, Current Mode, PWM  
output only on Even group and BEMF read  
on Even group  
x00  
x01  
x10  
x10  
000  
001  
100  
101  
110  
110  
Even  
Odd  
0
1
0
1
0
1
0
1
0
1
Sensorless mode, Current Mode, PWM  
output only on Odd group and BEMF read  
on Odd group  
1
Sensorless mode, Current Mode, PWM  
output on alternate groups but BEMF read  
only on Even group  
Even  
Odd  
Sensorless mode, Current Mode, PWM  
output on alternate groups but BEMF read  
only on Odd group  
Sensorless mode, Voltage Mode, PWM  
output only on Even group and BEMF read  
on Even group  
Even  
Odd  
Sensorless mode, Voltage Mode, PWM  
output only on Odd group and BEMF read  
on Odd group  
After D  
event  
0
Sensorless mode, Voltage Mode, PWM  
output only on Even group and BEMF  
Read on Even group  
Even  
Odd  
0
Sensorless mode, Voltage Mode, PWM  
output only on Odd group and BEMF Read  
on Odd group  
Sensorless mode, Voltage Mode, PWM  
output on alternate groups but BEMF read  
only on Even group  
Even  
Odd  
Sensorless mode, Voltage Mode, PWM  
output on alternate groups but BEMF read  
on Odd group  
Sensorless mode, Current or Voltage  
Mode, PWM output on both groups, BEMF  
read on either group  
Even and  
Odd  
x
x
x11  
xxx  
x
x
Odd or  
Even  
Sensor Mode, in any PWM output configu-  
ration, BEMF read on either group  
1
Not Used  
Other cases  
BEMF reading forbidden  
51/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
8.1.4.2 Delay Manager  
Figure 32. Overview of MTIM Timer  
MCRA register  
SWA bit  
T
ratio  
ck  
Z
1
§
clr  
8-bit Up Counter MTIM  
8
0
C
Z
Z
D
H
§
§
MDREG [D ]  
MZREG [Z ]  
n
n
Compare  
§
MZPRV [Z  
]
MCRB register  
SDM bit  
n-1  
§
MCOMP [C  
]
n+1  
D
S
Compare  
To interrupt generator  
To interrupt generator  
To interrupt generator  
C
C
D
S,H  
§
= Register updated on R event  
Z
This part of the MTC contains all the time-related  
functions, its architecture is based on an 8-bit shift  
left/shift right timer shown in Figure 32. The MTIM  
timer includes:  
Table 16. Switched and Autoswitched Modes  
MCOMP User  
SWA bit Commutation Type  
access  
0
1
Switched mode  
Autoswitched mode  
Read/Write  
Read only  
– An auto-updated prescaler  
– A capture/compare register for software demag-  
netization simulation (MDREG)  
Switched Mode  
– Two cascaded capture register (MZREG and  
MZPRV) for storing the times between two con-  
secutive BEMF zero crossings (Z events)  
This feature allows the motor to be run step-by-  
step. This is useful when the rotor speed is still too  
low to generate a BEMF. It can also run other  
kinds of motor without BEMF generation such as  
induction motors or switch reluctance motors. This  
mode can also be used for autoswitching with all  
computation for the next commutation time done  
by software (hardware multiplier not used) and us-  
ing the powerful interrupt set of the peripheral.  
– An 8x8 bit multiplier for auto computing the next  
commutation time  
– One compare register for phase commutation  
generation (MCOMP)  
The MTIM timer module can work in two main  
modes. In switched mode the user must process  
the step duration and commutation time by soft-  
ware, in autoswitched mode the commutation ac-  
tion is performed automatically depending on the  
rotor position information and register contents.  
In this mode, the step time is directly written by  
software in the commutation compare register  
MCOMP. When the MTIM timer reaches this value  
a commutation occurs (C event) and the MTIM  
timer is reset.  
52/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
At this time all registers with a preload function are  
loaded (registers marked with (*) in Section 8.1.7).  
The CI bit of MISR is set and if the CIM bit in the  
MISR register is set an interrupt is generated.  
updated but also all the MTIM timer-related regis-  
ters will be shifted in the appropriate direction to  
keep their value. After it has been taken into ac-  
count, (at commutation) the RPI or RMI bit is reset.  
See Table 17.  
An overflow of the MTIM timer generates an RPI  
interrupt if the RIM bit is set.  
Only one update per step is allowed, so if both RPI  
and RMI are set together, RPI is taken into ac-  
count at the next commutation and RMI is used  
one commutation latter.  
The MTIM timer prescaler (Step ratio bits ST[3:0]  
in the MPRSR register) is user programmable. Ac-  
cess to this register is not allowed while the MTIM  
timer is running (access is possible only before the  
starting the timer by means of the MOE bit) but the  
prescaler contents can be incremented/decre-  
mented at the next commutation event by setting  
the RMI (decrement) or RPI (increment) bits in the  
MISR register. When this method is used, at the  
next commutation event the prescaler value will be  
In switched mode, BEMF and demagnetization de-  
tection are already possible in order to pass in au-  
toswitched mode as soon as possible but Z and D  
events do not affect the timer contents.  
Warning: In this mode, MCOMP must never be  
written to 0.  
Table 17. Step Ratio Update  
Ratio Increment  
(Slow Down)  
Ratio Decrement  
(Speed-Up)  
MOE bit SWA bit Clock State  
Read  
0
1
1
x
0
1
Disabled  
Enabled  
Enabled  
Write the ST[3:0] value directly in the MPRSR register  
Always  
possible  
Set RPI bit in the MISR register till Set RMI bit in the MISR register till  
next commutation  
next commutation  
Automatically updated according to MZREG value  
53/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Figure 33. Step Ratio Functional Diagram  
4MHz  
R+  
MTIM Timer = FFh?  
+1  
1 / 2  
4
MPRSR Register  
ST[3:0] Bits  
1 / 2Ratio  
Tratio  
-1  
Zn < 55h?  
R-  
ck  
2 MHz - 62.5 Hz  
MTIM Timer control over T  
and register operation  
ratio  
MTIM Timer Overflow  
Begin  
Z Capture with MTIM Timer Underflow (Zn < 55h)  
Begin  
No  
No  
Ratio < Fh?  
Ratio > 0?  
Yes  
Yes  
Ratio = Ratio + 1  
Ratio = Ratio - 1  
Zn = Zn x 2  
Zn+1 = Zn+1 x 2  
Dn = Dn x 2  
Zn = Zn / 2  
Zn+1 = Zn+1/2  
Dn = Dn/2  
Counter = Counter x 2  
Counter = Counter/2  
Re-compute C  
Compute C  
n
n
End  
End  
Slow-down control  
Speed-up control  
54/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Autoswitched Mode  
When the timer reaches this value an RPI interrupt  
is generated (timer overflow).  
In this mode the MCOMP register content is auto-  
matically computed in real time as described be-  
low and in Figure 34. This register is READ ONLY.  
After each shift operation the multiply is recomput-  
ed for greater precision.  
The C event has no effect on the contents of the  
MTIM timer.  
Using either the MZREG or MZPRV register de-  
pends on the motor symmetry and type.  
When a Z event occurs the MTIM timer value is  
captured in the MZREG register, the previous cap-  
tured value is shifted into the MZPRV register and  
the MTIM timer is reset. See Figure 25.  
The MWGHT register gives directly the phase shift  
between the motor driven voltage and the BEMF.  
This parameter generally depends on the motor  
and on the speed.  
One of these two registers (depending on the DCB  
bit in the MCRA register) is multiplied with the con-  
tents of the MWGHT register and divided by 32.  
The result is loaded in the MCOMP compare reg-  
ister, which automatically triggers the next com-  
mutation (C event).  
Auto-updated Step Ratio Register: In switched  
mode, the MTIM timer is driven by software only  
and any prescaler change has to be done by soft-  
ware (see Section 8.1.4.2 for more details).  
– In autoswitched mode an auto-updated prescal-  
er always configures the MTIM timer for best ac-  
curacy. Figure 33 shows process of updating the  
Step Ratio bits:  
Table 18. Multiplier Result  
DCB bit  
Commutation Delay  
– When the MTIM timer value reaches FFh, the  
prescaler is automatically incremented in order  
to slow down the MTIM timer and avoid an over-  
flow. To keep consistent values, the MTIM regis-  
ter and all the relevant registers are shifted right  
(divided by two). The RPI bit in the MISR register  
is set and an interrupt is generated (if RIM is set).  
0
1
MCOMP = MWGHT x MZPRV / 32  
MCOMP = MWGHT x MZREG / 32  
When an overflow occurs during the multiply oper-  
ation, FFh is written in the MCOMP register and an  
interrupt (O event) is generated if enabled by the  
OIM bit in the MIMR register.  
– When a Z-event occurs, if the MTIM timer value  
is below 55h, the prescaler is automatically dec-  
remented in order to speed up the MTIM timer  
and keep precision better than 1.2%. The MTIM  
register and all the relevant registers are shifted  
left (multiplied by two). The RMI bit in the MISR  
register is set and an interrupt is generated if RIM  
is set.  
Figure 34. Commutation Processor Block  
§
MZREG [Z ]  
n
Z
§
MZPRV [Z  
]
– If the prescaler contents reach the value 0, it can  
no longer be automatically decremented, the  
MTC continues working with the same prescaler  
value, i.e. with a lower accuracy. No RMI inter-  
rupt can be generated.  
n-1  
MCRA Register  
DCB bit  
n-1  
n
– If the prescaler contents reach the value 15, it  
can no longer be automatically incremented.  
When the timer reaches the value FFh, the pres-  
caler and all the relevant registers remain un-  
changed and no interrupt is generated, the timer  
clock is disabled, and its contents stay at FFh  
The PWM is still generated and the D and Z de-  
tection circuitry still work, enabling the capture of  
the maximum timer value.  
MWGHT [a  
]
n+1  
8
8
O
To  
interrupt  
generator  
A x B / 32  
MCRA Register  
SWA bit  
8
3
set  
§
The automatically updated registers are: MTIM,  
MZREG, MZPRV, MCOMP and MDREG. Access  
to these registers is summarized in Table 21.  
MCOMP [C  
]
n+1  
§
= Register updated on R event  
55/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Table 19. MTIM Timer-related Registers  
These configuration bits are:  
CPB, HDM, SDM and OS2 in the MCRB register  
and IS[1:0], OO[5:0] in the MPHST register.  
Name  
MTIM  
Reset Value  
00h  
Contents  
Timer Value  
MZPRV  
MZREG  
MCOMP  
MDREG  
00h  
Capture Zn-1  
Capture Zn  
00h  
Note on initializing the MTC: As shown in Table  
21 all the MTIM timer registers are in read-write  
mode until the MTC clock is enabled (with the  
MOE and DAC bits). This allows the timer, prescal-  
er and compare registers to be properly initialized  
for start-up.  
In sensorless mode, the motor has to be started in  
switched mode until a BEMF voltage is present on  
the inputs. This means the prescaler ST[3:0] bits  
and MCOMP register have to be modified by soft-  
ware. When running the ST[3:0] bits can only be  
incremented/decremented, so the initial value is  
very important.  
00h  
Compare Cn+1  
Demagnetization Dn  
00h  
Note on using the auto-updated MTIM timer:  
The auto-updated MTIM timer works accurately  
within its operating range but some care has to be  
taken when processing timer-dependent data such  
as the step duration for regulation or demagnetiza-  
tion.  
For example, if an overflow occurs when calculat-  
ing  
a
software end of demagnetization  
(MCOMP+demagnetization_time>FFh), the value  
that is stored in MDREG will be:  
When starting directly in autoswitched mode (in  
sensor mode for example), write an appropriate  
value in the MZREG and MZPRV register to per-  
form a step calculation as soon as the clock is en-  
abled.  
7Fh+(MCOMP+demagnetization_time-FFh)/2.  
Note on commutation interrupts: It is good prac-  
tice to modify the configuration for the next step as  
soon as possible, that is, within the commutation  
interrupt routine.  
All registers that need to be changed at each step  
have a preload register that enables the modifica-  
tions for a complete new configuration to be per-  
formed at the same time (at C event in normal  
mode or when writing the MPHST register in direct  
access mode).  
56/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
The Figure 35 gives the step ratio register value  
(left axis) and the number of BEMF sampling dur-  
ing one electrical step with the corresponding ac-  
curacy on the measure (right axis) as a function of  
the mechanical frequency.  
At f  
= 4 MHz, the range covered by the Step  
CPU  
Ratio mechanism goes from 2.39 to 235000 (pole  
pair x rpm) with a minimum accuracy of 1.2% on  
the step period.  
To read the number of samples for Zn within one  
step (right Y axis), select the mechanical frequen-  
cy on the X axis and the sampling frequency curve  
used for BEMF detection (PWM frequency or  
measurement window frequency). For example,  
for N.Frpm = 15000 and a sampling frequency of  
20 kHz, there are approximately 10 samples in  
one step and there is a 10% error rate on the  
measurement.  
For a given prescaler value (step ratio register) the  
mechanical frequency can vary between two fixed  
values shown on the graph as the segment ends.  
In autoswitched mode, this register is automatical-  
ly incremented/decremented when the step fre-  
quency goes out of this segment.  
Figure 35. Step Ratio Bits decoding and accuracy results and BEMF Sampling Rate  
avg Zn ~ 55h 1.2%  
avg Zn ~ 7Fh 0.6%  
ST[3:0]  
avg Zn ~ FFh 0.4%  
Step Ratio (Decimal)  
BEMF  
samples  
Zn/Zn  
0
1
2
3
1
100%  
Fn+1 = 2.Fn  
200 Hz  
4
5
avg Zn ~ 55h 1.2%  
20 kHz  
3.Fn+1 = 6.Fn  
6
avg Zn ~ 7Fh 0.6%  
avg Zn ~ FFh 0.4%  
2
4
7
50%  
3.Fn  
Fn  
8
9
10  
11  
12  
13  
14  
15  
10 10%  
0%  
N.Frpm  
F
= 6.N.F  
= N.F / 10 N.F = 10.F  
step  
step  
rpm  
F
: Electrical step frequency  
step  
N: Pole pair number  
57/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Table 20. Step Frequency/Period Range  
Step Ratio Bits  
ST[3:0]  
Maximum  
Step Frequency  
Minimum  
Step Frequency  
Minimum  
Step Period  
Maximum  
Step Period  
0000  
0001  
0010  
0011  
0100  
0101  
0110  
0111  
1000  
1001  
1010  
1011  
1100  
1101  
1110  
1111  
23.5 kHz  
11.7 kHz  
5.88 kHz  
2.94 kHz  
1.47 kHz  
735 Hz  
7.85 kHz  
3.93 kHz  
1.96 kHz  
980 Hz  
42.5 µs  
85 µs  
127.5 µs  
255 µs  
170 µs  
340 µs  
680 µs  
1.36 ms  
2.72 ms  
5.44 ms  
10.9 ms  
21.8 ms  
43.6 ms  
87 ms  
510 µs  
1.02 ms  
2.04 ms  
4.08 ms  
8.16 ms  
16.32 ms  
32.6 ms  
65.2 ms  
130 ms  
261 ms  
522 ms  
1.04 s  
490 Hz  
245 Hz  
367 Hz  
123 Hz  
183 Hz  
61.3 Hz  
30.7 Hz  
15.4 Hz  
7.66 Hz  
3.83 Hz  
1.92 Hz  
0.958 Hz  
0.479 Hz  
0.240 Hz  
91.9 Hz  
45.9 Hz  
22.9 Hz  
11.4 Hz  
5.74 Hz  
2.87 Hz  
1.43 Hz  
0.718 Hz  
174 ms  
349 ms  
697 ms  
1.40 s  
2.08 s  
4.17 s  
Table 21. Modes of Accessing MTIM Timer-Related Registers  
State of MCRA Register Bits  
SWA bit MOE bit  
Access to MTIM Timer Related Registers  
RST bit  
Mode  
Read Only Access  
Read / Write Access  
MTIM, MZPRV, MZREG, MCOMP,  
MDREG, ST[3:0]  
0
0
0
Configuration Mode  
MCOMP, MDREG,  
RMI bit of MISR:  
0: No action  
1: Decrement ST[3:0]  
MTIM, MZPRV,  
MZREG, ST[3:0]  
0
0
1
Switched Mode  
RPI bit of MISR:  
0: No action  
1: Increment ST[3:0]  
MTIM, MZPRV, MZREG, MCOMP,  
MDREG, ST[3:0]  
0
0
1
1
0
1
Emergency Stop  
MTIM, MZPRV,  
MDREG,RMI, RPI bit of MISR:  
Set by hardware, (increment ST[3:0])  
Cleared by software  
Autoswitched Mode MZREG, MCOMP,  
ST[3:0]  
58/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
8.1.4.3 PWM Manager  
The PWM signal is directed to the channel manag-  
er that connects it to the programmed outputs (see  
Figure 38).  
The PWM manager controls the motor via the six  
output channels in voltage mode or current mode  
depending on the V0C1 bit in the MCRA register.  
A block diagram of this part is given in Figure 36.  
Current Mode  
In current mode, the PWM output signal is gener-  
ated by a combination of the output of the meas-  
urement window generator (see Figure 37) and  
the output of the current comparator, and is direct-  
ed to the output channel manager as well (Figure  
38).  
Voltage Mode  
In Voltage mode (V0C1 bit = ‘0’), the PWM is gen-  
erated by the 16-bit A Timer.  
Its duty cycle is programmed by software (refer to  
Section 8.3 16-BIT TIMER) as required by the ap-  
plication (speed regulation for example).  
The current reference is provided to the compara-  
tor by the PWM output of the 16-bit Timer (0.25%  
accuracy), filtered through a RC filter (external ca-  
pacitor on pin OCP1A and an internal voltage di-  
vider 30K and 70K).  
The current comparator is used for safety purpos-  
es as a current limitation. For this feature, the de-  
tected current must be present on the MCCFI pin  
and the current limitation must be present on pin  
OCP1A. This current limitation is fixed by a voltage  
reference depending on the maximum current ac-  
ceptable for the motor. This current limitation is  
The detected current input must be present on the  
MCCFI pin.  
To avoid spurious commutations due to parasitic  
noise after switching on the PWM, a 2.5-µs filter  
can be applied on the comparator output by set-  
ting the CFF bit in the MCRB register.  
generated with the V  
voltage by means of an  
DD  
external divider but can also be adjusted with an  
external reference voltage (< 3.7 V). The external  
components are adjusted by the user depending  
on the application needs. In Voltage mode, it is  
mandatory to set a current limitation.  
The On state of the resulting PWM starts at the  
end of the measurement window (rising edge),  
and ends either at the beginning of the next meas-  
urement window (falling edge), or when the cur-  
rent level is reached.  
In sensorless mode the BEMF zero crossing is  
done during the PWM off time.  
Figure 36. Current Feedback  
16-bit Timer - PWM  
MCRA  
Register  
MCRA Register  
CFF bit  
V0C1 bit  
R1  
(V)  
R2  
(I)  
2.5-µs Filter  
Sampling frequency  
V
To Phase State  
Control  
DD  
MCCFI  
OCP1A  
R
+
-
1ext  
(I)  
V
CREF  
(V)  
C
EXT  
R
2ext  
LEGEND:  
(I): Current mode  
(V): Voltage mode  
Common Mode = V - (1,4...1,0)V  
DD  
V
MAX = V - 1,3 V  
CREF  
DD  
Power down mode  
59/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
The measurement window frequency can be pro-  
grammed between 195 Hz and 25 kHz by the  
means of the SA[3:0] bits in the MPRSR register.  
In sensorless mode this measurement window can  
be used to detect either End of Demagnetization  
or BEMF zero crossing events. Its width can be  
defined between 5µs and 30µs in sensorless  
mode by the OT[1:0] bits in the MPOL register. In  
sensor mode (SR = 1) this off time is fixed at  
1.25µs.  
Table 23. Sampling Frequency Selection  
SA3 SA2 SA1 SA0  
Sampling Frequency  
25.0 kHz  
20.0 kHz  
18.1 kHz  
15.4 kHz  
12.5 kHz  
10.0 kHz  
6.25 kHz  
3.13 kHz  
1.56 kHz  
1.25 kHz  
1.14 kHz  
961 Hz  
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Table 22. Off-Time Table  
Off-Time  
Sensorless Mode  
(SR bit = 0)  
Off-Time  
Sensor Mode  
(SR bit = 1)  
OT1  
bit  
OT0  
bit  
0
0
1
1
0
1
0
1
5 µs  
10 µs  
15 µs  
30 µs  
781 Hz  
1.25 µs  
625 Hz  
390 Hz  
195 Hz  
Figure 37. Sampling clock generation block  
MPRSR Register  
SA[3:0] bits  
4
1
4 MHz  
T
sampling  
Frequency logic  
Off-Time logic  
R
S
Q
T
off  
2
1
( ) The MTC controller input frequency must always be 4 MHz,  
whatever the crystal frequency is. The appropriate internal  
frequency can be selected in the Miscellaneous register.  
OT[1:0] bits  
MPOL Register  
60/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
8.1.4.4 Channel Manager  
MPHST Phase State Register  
The channel manager consists of:  
A preload register enables software to asynchro-  
nously update (during the previous commutation  
interrupt routine for example) the channel configu-  
ration for the next step: the OO[5:0] bits in the  
MPHST register are copied to the Phase register  
on a C event.  
– A Phase State register with preload and polarity  
function  
– A multiplexer to direct the PWM to the odd and/  
or even channel group  
– A tristate buffer asynchronously driven by an  
emergency input.  
Table 24. Output State  
OP[5:0] bit  
OO[5:0] bit  
MCO[5:0] Pin  
1 (OFF)  
The block diagram is shown in Figure 38.  
0
0
1
1
0
1
0
1
0-(PWM allowed)  
0 (OFF)  
1-(PWM allowed)  
Figure 38. Channel Manager Block Diagram  
MCRA Register  
Notes:  
Reg  
V0C1 bit  
Updated/Shifted on  
R
16-bit Timer PWM  
Updated with Reg  
on C  
n+1  
Reg  
n
16-bit timer PWM  
V
I
V
I
I
Current Mode  
Voltage Mode  
V
S Q  
Sampling frequency  
events:  
Commutation  
C
Z
BEFM  
Zero-crossing  
D
S,H  
Current comparator  
output  
End Of  
Demagnetization  
E
+/-  
Emergency Stop  
Ratio Updated (+1 or -1)  
2.5-µs  
Filter  
R
MCRA Register  
CFF bit  
O
1
Multiplier  
Overflow  
R
Branch taken after C event  
Branch taken after D event  
2
MCRA Register  
DAC bit  
MCRA Register  
SR bit  
C
MPHST Register  
OO bits*  
Phase Register*  
6
MCRB Register  
OS[2:0] bits*  
n
3
MPAR Register  
OE[5:0] bits  
6
Channel [5:0]  
MPOL Register  
OP[5:0] bits  
x6  
x6  
6
MRCA Register  
MOE bit  
1
* = Preload register, changes taken into account at next C event.  
61/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Direct access to the phase register is also possible  
when the DAC bit in the MCRA register is set.  
The OS[2:0] bits in the MCRB register allow the  
PWM configuration to be configured for each case  
as shown in Figure 40, Figure 41 and Figure 39.  
This configuration depends also on the current/  
voltage mode (V0C1 bit in the MCRA register) be-  
cause the OS[2:0] have not the same meaning in  
voltage mode and in current mode.  
Table 25. DAC and MOE Bit Meaning  
Effect on  
Output  
Effect on MTIM  
Timer  
MOE bit DAC bit  
0
1
x
High Z  
Clock disabled  
During demagnetization, the OS2 bit is used to  
control PWM mode, and it is latched in a preload  
register so it can be modified when a commutation  
event occurs.  
Standard run-  
ning mode  
Standard run-  
ning mode  
0
MPHST value  
1
1
same as MPOL Clock disabled  
value  
The OS[1:0] bits are used to control the PWM be-  
tween the D and C events.  
The polarity register is used to match the polarity  
of the power drivers keeping the same control log-  
ic and software. If one of the OPx bits in the MPOL  
register is set, this means the switch x is ON when  
Warning: In Voltage Mode the OS[2:0] bits have a  
special configuration value: OS[2:0] = 010.  
In this mode, there is NO current limitation and NO  
PWM applied to active outputs. The active outputs  
are always at 100% whether in demagnetization,  
or normal mode.  
Note about demagnetization speed-up: during  
demagnetization the voltage on the winding has to  
be as high as possible in order to reduce the de-  
magnetization time. Software can apply a different  
PWM configuration on the outputs between the C  
and D events, to force the free wheeling on the ap-  
propriate diodes to maximize the demagnetization  
voltage.  
MCOx is V  
.
DD  
Each output status depends also on the momen-  
tary state of the PWM, its group (odd or even), and  
the peripheral state.  
PWM Features  
The outputs can be split in two PWM groups in or-  
der to differentiate the high side and the low side  
switches. This output property can be pro-  
grammed using the OE[5:0] bits in the MPAR reg-  
ister.  
Table 26. Meaning of the OE[5:0] Bits  
Emergency Feature  
OE[5:0]  
Channel group  
Even channel  
Odd channel  
When the NMCES pin goes low  
0
1
– The tristate output buffer is put in HiZ asynchro-  
nously  
– The MOE bit in the MCRA register is reset  
The multiplexer directs the PWM to the upper  
channel, the lower channel or both of them alter-  
natively or simultaneously according to the periph-  
eral state.  
– An interrupt request is sent to the CPU if the EIM  
bit in the MIMR register is set  
This bit can be connected to an alarm signal from  
the drivers, thermal sensor or any other security  
component.  
This means that the PWM can affect any of the up-  
per or lower channels allowing the selection of the  
most appropriate reference potential when free-  
wheeling the motor in order to:  
This feature functions even if the MCU oscillator is  
off.  
– Improve system efficiency  
– Speed up the demagnetization phase  
– Enable Back EMF zero crossing detection.  
62/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Figure 39. Step Behavior of One Output Channel MCO[n] in Voltage Mode  
(Voltage Mode without polarity effect)  
OS2 PWM behavior before D  
OS[1:0]  
00  
PWM behavior after D  
On Even Channels  
On Odd Channels  
Alternate Odd/Even  
On all active Channels  
xxx  
OS2  
OS1  
OS0  
0
1
Not Alternate  
Alternate  
01  
10  
11  
Step  
Demagnetization  
1
0
0
Even  
1 Odd  
000  
001  
0
1
Even  
Odd  
0 Even  
010  
011  
1
Odd  
Even  
Odd  
0
1
Even  
Odd  
0
1
100  
101  
Even  
Odd  
0
1
Even  
Odd  
Even  
Odd  
0
1
110  
111  
Even  
Odd  
0
1
!
WARNING: OS[2:0] = 010 has NO current regulation!  
63/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Figure 40. Step Behavior of One Output Channel MCO[n] in Current / Sensorless Mode  
(Current Mode without polarity effect, sensorless mode: SR = 0)  
OS2 PWM behavior before D  
OS[1:0]  
PWM behavior after D  
0
On Even Channels  
00  
01  
10  
11  
On Even Channels  
On Odd Channels  
Alternate Odd/Even  
On all active Channels  
1
On Odd Channels  
Step  
Demagnetization  
1
0
x
xx  
1
0
00  
11  
T
0
1
off  
10  
01  
1
0
1
0
01  
11  
10  
00  
T
1
0
off  
1
0
xx  
x
OS0  
OS1  
OS2  
Figure 41. Step Behavior of One Output Channel MCO[n] in Current / Sensor Mode  
(Current Mode without polarity effect, sensor mode: SR = 1)  
OS2 Not used  
-
OS[1:0]  
PWM behavior after D  
00  
01  
10  
11  
On Even Channels  
On Odd Channels  
Alternate Odd/Even  
On all active Channels  
Step  
1
0
xx  
00  
11  
1.25us  
1.25us  
10  
01  
01  
11  
10  
00  
xx  
In sensor mode, there is no demagnetization event and the PWM behavior is the  
same for the complete step time.  
OS1  
OS0  
64/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
8.1.5 Low Power Modes  
8.1.6 Interrupts  
Interrupt Event  
Before executing a HALT or WFI instruction, soft-  
ware must stop the motor, and may choose to put  
the outputs in high impedance.  
Enable Exit Exit  
Control from from  
Event  
Flag  
Bit  
Wait Halt  
Yes No  
Yes No  
Yes No  
Yes No  
Yes No  
Yes No  
Yes No  
Ratio increment  
RPI  
RMI  
OI  
Mode  
Description  
No effect on MTC interface.  
MTC interrupts exit from Wait mode.  
MTC registers are frozen.  
RIM  
Ratio decrement  
Multiplier overflow  
Emergency Stop  
BEMF Zero-Crossing  
End of Demagnetization  
Commutation  
WAIT  
OIM  
EIM  
ZIM  
DIM  
CIM  
EI  
ZI  
In Halt mode, the MTC interface is inactive.  
The MTC interface becomes operational  
again when the MCU is woken up by an in-  
terrupt with “exit from Halt mode” capability.  
DI  
HALT  
CI  
The MTC interrupt events are connected to the  
three interrupt vectors (see Section 4 INTER-  
RUPTS).  
They generate an interrupt if the corresponding  
Enable Control Bit is set and the I-bit in the CC  
register is reset (RIM instruction).  
65/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
8.1.7 Register Description  
DEMAGNETIZATION REGISTER (MDREG)  
Read/Write  
TIMER COUNTER REGISTER (MTIM)  
Read/Write  
Reset Value: 0000 0000 (00h)  
Reset Value: 0000 0000 (00h)  
7
0
7
0
DN7  
DN6  
DN5  
DN4  
DN3  
DN2  
DN1  
DN0  
T7  
T6  
T5  
T4  
T3  
T2  
T1  
T0  
Bits 7:0 = DN[7:0]: D Value.  
These bits contain the compare value for software  
demagnetization (D ) and the captured value for  
Bits 7:0 = T[7:0]: MTIM Counter Value.  
These bits contain the current value of the 8-bit up  
counter.  
N
hardware demagnetization (D ).  
H
A WEIGHT REGISTER (MWGHT)  
N
CAPTURE Z  
REGISTER (MZPRV)  
n-1  
Read/Write  
Read/Write  
Reset Value: 0000 0000 (00h)  
Reset Value: 0000 0000 (00h)  
7
0
7
0
AN7  
AN6  
AN5  
AN4  
AN3  
AN2  
AN1  
AN0  
ZP7  
ZP6  
ZP5  
ZP4  
ZP3  
ZP2  
ZP1  
ZP0  
Bits 7:0 = AN[7:0]: A Weight Value.  
Bits 7:0 = ZP[7:0]: Previous Z Value.  
These bits contain the A weight value for the mul-  
N
These bits contain the previous captured BEMF  
tiplier. In autoswitched mode the MCOMP register  
is automatically loaded with:  
value (Z ).  
N-1  
Z x MWGHT  
ZN-1 x MWGHT  
32(d)  
n
or  
(*)  
CAPTURE Z REGISTER (MZREG)  
n
32(d)  
Read/Write  
when a Z event occurs.  
(*) depending on the DCB bit in the MCRA regis-  
ter.  
Reset Value: 0000 0000 (00h)  
7
0
PRESCALER AND SAMPLING REGISTER  
(MPRSR)  
ZC7  
ZC6  
ZC5  
ZC4  
ZC3  
ZC2  
ZC1  
ZC0  
Read/Write  
Bits 7:0 = ZC[7:0]: Current Z Value.  
Reset Value: 0000 0000 (00h)  
These bits contain the current captured BEMF val-  
ue (Z ).  
N
7
0
SA3  
SA2  
SA1  
SA0  
ST3  
ST2  
ST1  
ST0  
COMPARE C  
REGISTER (MCOMP)  
n+1  
Read/Write  
Reset Value: 0000 0000 (00h)  
Bits 7:4 = SA[3:0]: Sampling Ratio.  
These bits contain the sampling ratio value for cur-  
rent mode. Refer to Table 23.  
7
0
DC7  
DC6  
DC5  
DC4  
DC3  
DC2  
DC1  
DC0  
Bits 3:0 = ST[3:0]: Step Ratio.  
These bits contain the step ratio value. It acts as a  
prescaler for the MTIM timer and is auto incre-  
mented/decremented with each R+ or R- event.  
Refer to Table 20.  
Bits 7:0 = DC[7:0]: Next Compare Value.  
These bits contain the compare value for the next  
commutation (C ).  
N+1  
66/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
INTERRUPT MASK REGISTER (MIMR)  
Read/Write (except bits 7:6)  
Reset Value: 0000 0000 (00h)  
INTERRUPT STATUS REGISTER (MISR)  
Read/Write  
Reset Value: 0000 0000 (00h)  
7
0
7
0
HST  
CL  
RIM  
OIM  
EIM  
ZIM  
DIM  
CIM  
0
RPI  
RMI  
OI  
EI  
ZI  
DI  
CI  
Bit 7 = HST: Hysteresis Comparator Value.  
Bit 7 = Reserved. Forced by hardware to 0.  
This read only bit contains the hysteresis compa-  
rator output.  
Bit 6 = RPI: Ratio Increment interrupt flag.  
Autoswitched mode (SWA bit = 0):  
0: No R+ interrupt pending  
0: Demagnetization/BEMF comparator is under  
V
REF  
1: Demagnetization/BEMF comparator is above  
1: R+ Interrupt pending  
V
REF  
Switched mode (SWA bit = 1):  
0: No R+ action  
Bit 6 = CL: Current Loop Comparator Value.  
This read only bit contains the current loop compa-  
rator output value.  
1: The hardware will increment the ST[3:0] bits  
when the next commutation occurs and shift all  
timer registers right.  
0: Current detect voltage is under V  
CREF  
1: Current detect voltage is above V  
CREF  
Bit 5 = RMI: Ratio Decrement interrupt flag.  
Autoswitched mode (SWA bit = 0):  
0: No R- interrupt pending  
Bit 5 = RIM: Ratio update Interrupt Mask bit.  
0: Ratio update interrupts (R+ and R-) disabled  
1: Ratio update interrupts (R+ and R-) enabled  
1: R- Interrupt pending  
Switched mode (SWA bit = 1):  
0: No R- action  
Bit 4 = OIM: Multiplier Overflow Interrupt Mask bit.  
0: Multiplier Overflow interrupt disabled  
1: Multiplier Overflow interrupt enabled  
1: The hardware will decrement the ST[3:0] bits  
when the next commutation occurs and shift all  
timer registers left.  
Bit 3 = EIM: Emergency stop Interrupt Mask bit.  
0: Emergency stop interrupt disabled  
1: Emergency stop interrupt enabled  
Bit 4 = OI: Multiplier Overflow interrupt flag.  
0: No Multiplier Overflow interrupt pending  
1: Multiplier Overflow interrupt pending  
Bit 2 = ZIM: Back EMF Zero-crossing Interrupt  
Mask bit.  
0: BEMF Zero-crossing Interrupt disabled  
1: BEMF Zero-crossing Interrupt enabled  
Bit 3 = EI: Emergency stop Interrupt flag.  
0: No Emergency stop interrupt pending  
1: Emergency stop interrupt pending  
Bit 2 = ZI: BEMF Zero-crossing interrupt flag.  
0: No BEMF Zero-crossing Interrupt pending  
1: BEMF Zero-crossing Interrupt pending  
Bit 1 = DIM: End of Demagnetization Interrupt  
Mask bit.  
0: End of Demagnetization interrupt disabled  
1: End of Demagnetization interrupt enabled if the  
HDM or SDM bit in the MCRB register is set  
Bit 1 = DI: End of Demagnetization interrupt flag.  
0: No End of Demagnetization interrupt pending  
1: End of Demagnetization interrupt pending  
Bit 0 = CIM: Commutation Interrupt Mask bit  
0: Commutation Interrupt disabled  
1: Commutation Interrupt enabled  
Bit 0 = CI: Commutation interrupt flag  
0: No Commutation Interrupt pending  
1: Commutation Interrupt pending  
67/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Table 27. Step Ratio Update  
Bit 4 = DAC: Direct Access to phase state register.  
0: No Direct Access (reset value). In this mode all  
the registers with a preload register are taken  
into account at the C event.  
1: Direct Access enabled. In this mode, write a val-  
ue in the MPHST register to access the outputs  
directly. All other registers with a preload regis-  
ter are taken into account at the same time.  
Ratio  
Read Increment  
Ratio  
Decrement  
MOE SW Clock  
bit A bit State  
(Slow Down) (Speed-Up)  
Write the ST[3:0] value di-  
rectly in the MPRSR register  
Disa-  
bled  
0
1
1
x
0
1
Al-  
Set RPI bit in Set RMI bit in  
Ena- ways the MISR reg- the MISR reg-  
bled possi- ister till next ister till next  
ble  
commutation commutation  
Table 29. DAC Bit Meaning  
Ena-  
bled  
Updated automatically ac-  
cording to MZREG value  
MOE DAC  
bit bit  
Effect on MTIM  
Timer  
Effect on Output  
0
x
High Z  
Clock disabled  
CONTROL REGISTER A (MCRA)  
Read/Write  
Standard running  
mode  
Standard running  
mode  
1
0
Reset Value: 0000 0000 (00h)  
MPHST register val-  
ue (depending on  
MPOL register value)  
1
1
Clock disabled  
7
0
MOE  
RST  
SR  
DAC V0C1 SWA  
CFF  
DCB  
Note 1: When the MTC clock is disabled, the  
MTIM counter is not reset but as in this case it is in  
write access, a reset can be done by software.  
Bit 7 = MOE: Output Enable bit.  
0: Outputs and Clocks disabled  
1: Outputs and Clocks enabled  
Note 2: In direct access mode, only logical levels  
(0 or 1) can be output on the MCOx pins. There is  
no PWM signal generation in this mode.  
MOE bit  
MCO[5:0] Output Pin State  
Tristate  
0
1
Output enabled  
Bit 3 = V0C1: Voltage/Current Mode  
0: Voltage Mode  
1: Current Mode  
Bit 6 = RST: Reset MTC registers.  
Software can set this bit to reset all MTC registers  
without resetting the ST7.  
0: No MTC register reset  
1: Reset all MTC registers  
Bit 2 = SWA: Switched/Autoswitched Mode  
0: Switched Mode  
1: Autoswitched Mode  
Table 30. Switched and Autoswitched Modes  
Bit 5 = SR: Sensor ON/OFF.  
0: Sensorless mode  
1: Sensor mode  
MCOMP Register  
SWA bit Commutation Type  
access  
0
1
Switched mode  
Read/Write  
Read only  
Table 28. Sensor Mode Selection  
Autoswitched mode  
SR  
bit  
OS2 bit Behavior of the output  
Mode  
Bit 1 = CFF: Current Feedback Filter  
0: Current Feedback Filter disabled  
1: Current Feedback Filter enabled  
enable  
PWM  
Sensorsnot  
used  
OS2  
enabled  
“Before D” behavior and  
“after D” behavior  
0
1
Sensors  
used  
OS2  
disabled  
Only “after D” behavior  
Bit 0 = DCB: Data Capture bit  
0: Use MZPRV (Z -1) for multiplication  
N
1: Use MZREG (Z ) for multiplication  
N
68/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Table 31. Multiplier Result  
Table 32. Step Behavior Summary  
DCB bit  
Commutation Delay  
MCOMP = MWGHT x MZPRV / 32  
MCOMP = MWGHT x MZREG / 32  
OS  
[1:0]  
bits  
OS2 PWM after C  
bit and before D  
PWM after D and  
before C  
Mode  
0
1
On even  
channels  
00  
CONTROL REGISTER B (MCRB)  
Read/Write  
Reset Value: 0000 0000 (00h)  
On odd  
channels  
Same as  
01  
10  
11  
0
1
x
0
1
x
after D and  
before C  
Continuous  
All active  
channels  
7
0
On even  
channels  
VR1  
VR0 CPB* HDM* SDM* OS2* OS1  
OS0  
00  
01  
On odd  
channels  
Bits 7:6 = VR[1:0]: BEMF/demagnetization Refer-  
ence threshold  
Alternate  
Unused  
10 Alternate odd/even  
These bits select the V  
following table.  
value as shown in the  
REF  
All active  
channels  
11  
VR1  
VR0  
V
Voltage threshold  
REF  
On even  
channels  
00  
0
0
1
1
0
1
0
1
0.2V  
0.6V  
1.2V  
2.5V  
On odd  
01  
channels  
10 Alternate odd/even  
All active  
channels  
11  
Bit 5 = CPB*: Compare Bit for Zero-crossing de-  
tection.  
0: Zero crossing detection on falling edge  
1: Zero crossing detection on rising edge  
On even  
channels  
00  
On odd  
01  
On even  
Channels  
channels  
10 Alternate odd/even  
All active  
channels  
Bit 4 = HDM*: Hardware Demagnetization event  
Mask bit  
0: Hardware Demagnetization disabled  
1: Hardware Demagnetization enabled  
11  
On even  
channels  
00  
On odd  
01  
On odd  
channels  
channels  
Bit 3 = SDM*: Software Demagnetization event  
Mask bit  
0: Software Demagnetization disabled  
1: Software Demagnetization enabled  
10 Alternate odd/even  
All active  
channels  
11  
On even  
channels  
00  
Bits 2:0 = OS2*,OS[1:0]: Operating output mode  
Selection bits  
On odd  
01  
channels  
Unused  
Refer to the Step behavior diagrams (Figure 39,  
Figure 40, Figure 41) and Table 32.  
10 Alternate odd/even  
All active  
channels  
11  
These bits are used to configure the various PWM  
output configurations.  
Note: For more details, see Step behavior dia-  
grams (Figure 39, Figure 40, and Figure 41).  
Note: The OS2 bit is the only one with a preload  
register.  
* Preload bits, new value taken into account at  
next C event.  
69/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
PHASE STATE REGISTER (MPHST)  
Read/Write  
Reset Value: 0000 0000 (00h)  
1: Zero-crossing and End of Demagnetization  
have same edge  
Bit 6 = REO: Read on Even or Odd channel bit  
0: Read the BEMF signal during the off time on  
even channels  
7
0
IS1*  
IS0* OO5* OO4* OO3* OO2* OO1* OO0*  
1: Read on odd channels  
Bits 7:6 = IS[1:0]*: Input Selection bits  
Bits 5:0 = OE[5:0]: Output Parity Mode.  
0: Output channel is Even  
1: Output channel Odd  
These bits select the input to connect to compara-  
tor as shown in the following table:  
Table 33. Input Channel Selection  
POLARITY REGISTER (MPOL)  
Read/Write  
Reset Value: 0000 0000 (00h)  
IS1  
0
IS0  
0
Channel selected  
MCIA  
0
1
MCIB  
1
0
MCIC  
7
0
1
1
Not Used  
OT1  
OT0  
OP5  
OP4  
OP3  
OP2  
OP1  
OP0  
Bits 5:0 =OO[5:0]*: Channel On/Off bits  
Bits 7:6 = OT[1:0]: Off Time selection.  
These bits are used to select the off time in sen-  
sorless mode as shown in the following table.  
These bits are used to switch channels on/off at  
the next C event if the DAC bit = 0 or directly if  
DAC = 1  
0: Channel Off, the relevant switch is OFF, no  
PWM possible  
1: Channel On the relevant switch is ON, PWM is  
possible.  
Table 35. Off-Time bit Meaning  
Off-Time  
Sensorless  
Mode (SR = 0)  
Off-Time  
Sensor Mode  
(SR = 1)  
OT1  
OT0  
Table 34. OO[5:0] Bit Meaning  
0
0
1
1
0
1
0
1
5 µs  
10 µs  
15 µs  
30 µs  
OO[5:0]  
Output Channel State  
Inactive  
1.25 µs  
0
1
Active  
Bits 5:0 = OP[5:0]: Output channel polarity.  
These bits are used together with the OO[5:0] bits  
in the MPHST register to control the output chan-  
nels.  
* Preload bits, new value taken into account at  
next C event.  
0: Output channel is Active Low  
1: Output channel is Active High.  
PARITY REGISTER (MPAR)  
Read/Write  
Reset Value: 0000 0000 (00h)  
Table 36. Output Channel State Control  
7
0
OP[5:0] bit  
OO[5:0] bit  
MCO[5:0] pin  
1 (Off)  
0
0
1
1
0
1
0
1
ZVD  
REO  
OE5  
OE4  
OE3  
OE2  
OE1  
OE0  
0 (PWM possible)  
0 (Off)  
1 (PWM possible)  
Bit 7 = ZVD: Z vs D edge polarity.  
0: Zero-crossing and End of Demagnetization  
have opposite edges  
70/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Note: The CPB, HDM, SDM, OS2 bits in the  
MCRB and the bits OE[5:0] are marked with *. It  
means that these bits are taken into account at the  
following commutation event (in normal mode) or  
when a value is written in the MPHST register  
when in direct access mode. For more details, re-  
fer to the description of the DAC bit in the MCRA  
register. The use of a Preload register allows all  
the registers to be updated at the same time.  
Warning: Access to Preload registers  
Special care has to be taken with Preload regis-  
ters, especially when using the ST7 BSET and  
BRES instructions on MTC registers.  
For instance, while writing to the MPHST register,  
you will write the value in the preload register.  
However, while reading at the same address, you  
will get the current value in the register and not the  
value of the preload register.  
All preload registers are loaded in the real regis-  
ters at the same time. In normal mode this is done  
automatically when a C event occurs, however in  
direct access mode (DAC bit = 1) the preload reg-  
isters are loaded as soon as a value is written in  
the MPHST register.  
71/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Figure 42. Detailed view of the MTC  
MOE bit  
MPOL Reg  
MPAR Reg  
MPHST Reg  
n
CFF bit  
V
I
V
2
I
1
MIMR Reg  
MISR Reg  
20µs / C  
72/131  
ST72141K2-Auto  
MOTOR CONTROLLER (Cont’d)  
Table 37. MTC Register Map and Reset Values  
Address  
(Hex.)  
Register  
Name  
7
6
5
4
3
2
1
0
MTIM  
Reset Value  
T7  
0
T6  
0
T5  
0
T4  
0
T3  
0
T2  
0
T1  
0
T0  
0
0060h  
0061h  
0062h  
0063h  
0064h  
0065h  
0066h  
0067h  
0068h  
0069h  
006Ah  
006Bh  
006Ch  
006Dh  
MZPRV  
Reset Value  
ZP7  
0
ZP6  
0
ZP5  
0
ZP4  
0
ZP3  
0
ZP2  
0
ZP1  
0
ZP0  
0
MZREG  
Reset Value  
ZC7  
0
ZC6  
0
ZC5  
0
ZC4  
0
ZC3  
0
ZC2  
0
ZC1  
0
ZC0  
0
MCOMP  
Reset Value  
DC7  
0
DC6  
0
DC5  
0
DC4  
0
DC3  
0
DC2  
0
DC1  
0
DC0  
0
MDREG  
Reset Value  
DN7  
0
DN6  
0
DN5  
0
DN4  
0
DN3  
0
DN2  
0
DN1  
0
DN0  
0
MWGHT  
Reset Value  
AN7  
0
AN6  
0
AN5  
0
AN4  
0
AN3  
0
AN2  
0
AN1  
0
AN0  
0
MPRSR  
Reset Value  
SA3  
0
SA2  
0
SA1  
0
SA0  
0
ST3  
0
ST2  
0
ST1  
0
ST0  
0
MIMR  
Reset Value  
HST  
0
CL  
0
RIM  
0
OIM  
0
EIM  
0
ZIM  
0
DIM  
0
CIM  
0
MISR  
Reset Value  
RPI  
0
RMI  
0
OI  
0
EI  
0
ZI  
0
DI  
0
CI  
0
0
MCRA  
Reset Value  
MOE  
0
RST  
0
SR  
0
DAC  
0
V0C1  
0
SWA  
0
CFF  
0
DCB  
0
MCRB  
Reset Value  
VR1  
0
VR0  
0
CPB  
0
HDM  
0
SDM  
0
OS2  
0
OS1  
0
OS0  
0
MPHST  
Reset Value  
IS1  
0
IS0  
0
OO5  
0
OO4  
0
OO3  
0
OO2  
0
OO1  
0
OO0  
MPAR  
Reset Value  
ZVD  
0
REO  
0
OE5  
0
OE4  
0
OE3  
0
OE2  
0
OE1  
0
OE0  
0
MPOL  
Reset Value  
OT1  
0
OT0  
0
OP5  
0
OP4  
0
OP3  
0
OP2  
0
OP1  
0
OP0  
0
Related Documentation  
AN1130: An Introduction to Sensorless Brushless  
DC Motor Drive Applications with the ST72141  
AN1082: Description of the ST72141 Motor Con-  
trol Peripherals  
AN1276: BLDC Motor Start Routine for the  
ST72141 Microcontroller  
AN1083: ST72141 BLDC Motor Control Software  
and Flowchart Example  
AN1321: Using the ST72141 Motor Control MCU  
in Sensor Mode  
AN1129: PWM Management for BLDC Motor  
Drives Using the ST72141  
73/131  
ST72141K2-Auto  
8.2 WATCHDOG TIMER (WDG)  
8.2.1 Introduction  
8.2.2 Main Features  
Programmable timer (64 increments of 12288  
The Watchdog timer is used to detect the occur-  
rence of a software fault, usually generated by ex-  
ternal interference or by unforeseen logical condi-  
tions, which causes the application program to  
abandon its normal sequence. The Watchdog cir-  
cuit generates an MCU reset on expiry of a pro-  
grammed time period, unless the program refresh-  
es the counter’s contents before the T6 bit be-  
comes cleared.  
CPU cycles)  
Programmable reset  
Reset (if watchdog activated) after a HALT  
instruction or when the T6 bit reaches zero  
Watchdog Reset indicated by status flag  
Figure 43. Watchdog Block Diagram  
RESET  
WATCHDOG CONTROL REGISTER (CR)  
T5  
WDGA T6  
T1  
T0  
T4  
T2  
T3  
7-BIT DOWNCOUNTER  
CLOCK DIVIDER  
f
CPU  
÷ 12288  
74/131  
ST72141K2-Auto  
WATCHDOG TIMER (Cont’d)  
8.2.3 Functional Description  
8.2.6 Register Description  
CONTROL REGISTER (CR)  
Read/Write  
The counter value stored in the CR register (bits  
T6:T0), is decremented every 12288 machine cy-  
cles, and the length of the timeout period can be  
programmed by the user in 64 increments.  
Reset Value: 0111 1111 (7Fh)  
If the watchdog is activated (the WDGA bit is set)  
and when the 7-bit timer (bits T6:T0) rolls over  
from 40h to 3Fh (T6 become cleared), it initiates a  
reset cycle pulling low the RESET pin for typically  
30µs.  
7
0
WDGA T6  
T5  
T4  
T3  
T2  
T1  
T0  
Bit 7= WDGA Activation bit.  
The application program must write in the CR reg-  
ister at regular intervals during normal operation to  
prevent an MCU reset. The value to be stored in  
the CR register must be between FFh and C0h  
(see Table 38 Watchdog Timing (fCPU = 8 MHz)):  
This bit is set by software and only cleared by  
hardware after a reset. When WDGA = 1, the  
watchdog can generate a reset.  
0: Watchdog disabled  
1: Watchdog enabled  
– The WDGA bit is set (watchdog enabled).  
– The T6 bit is set to prevent generating an imme-  
diate reset.  
Bit 6:0 = T[6:0] 7-bit timer (MSB to LSB).  
These bits contain the decremented value. A reset  
is produced when it rolls over from 40h to 3Fh (T6  
becomes cleared) if WDGA = 1.  
– The T5:T0 bits contain the number of increments  
which represents the time delay before the  
watchdog produces a reset.  
STATUS REGISTER (SR)  
Read/Write  
Table 38. Watchdog Timing (f  
= 8 MHz)  
CPU  
CR Register  
initial value  
WDG timeout period  
(ms)  
Reset Value*: 0000 0000 (00h)  
Max  
Min  
FFh  
C0h  
98.304  
1.536  
7
-
0
-
-
-
-
-
-
WDOGF  
Notes: Following a reset, the watchdog is disa-  
bled. Once activated it cannot be disabled, except  
by a reset.  
Bit 0 = WDOGF Watchdog flag.  
This bit is set by a watchdog reset and cleared by  
software or a power-on/off reset. This bit is useful  
for distinguishing power-on/off or external reset  
and watchdog reset.  
The T6 bit can be used to generate a software re-  
set (the WDGA bit is set and the T6 bit is cleared).  
If the watchdog is activated, the HALT instruction  
will generate a Reset.  
0: No Watchdog reset occurred  
1: Watchdog reset occurred  
8.2.4 Low Power Modes  
* Only by software and power-on/off reset  
Mode  
Description  
No effect on Watchdog.  
WAIT  
Immediate reset generation as soon as the  
HALT instruction is executed if the Watch-  
dog is activated (WDGA bit is set).  
HALT  
8.2.5 Interrupts  
None.  
75/131  
ST72141K2-Auto  
WATCHDOG TIMER (Cont’d)  
Table 39. Watchdog Timer Register Map and Reset Values  
Address  
(Hex.)  
Register  
Label  
7
6
5
4
3
2
1
0
WDGCR  
Reset Value  
WDGA  
0
T6  
1
T5  
1
T4  
1
T3  
1
T2  
1
T1  
1
T0  
1
0024h  
0025h  
WDGSR  
Reset Value  
-
0
-
0
-
0
-
0
-
0
-
0
-
0
WDOGF  
0
76/131  
ST72141K2-Auto  
8.3 16-BIT TIMER  
8.3.1 Introduction  
8.3.3 Functional Description  
8.3.3.1 Counter  
The timer consists of a 16-bit free-running counter  
driven by a programmable prescaler.  
The main block of the Programmable Timer is a  
16-bit free running upcounter and its associated  
16-bit registers. The 16-bit registers are made up  
of two 8-bit registers called high and low.  
It may be used for a variety of purposes, including  
measuring the pulse lengths of up to two input sig-  
nals (input capture) or generating up to two output  
waveforms (output compare and PWM).  
Counter Register (CR)  
Pulse lengths and waveform periods can be mod-  
ulated from a few microseconds to several milli-  
seconds using the timer prescaler and the CPU  
clock prescaler.  
– Counter High Register (CHR) is the most signifi-  
cant byte (MS Byte).  
– Counter Low Register (CLR) is the least signifi-  
cant byte (LS Byte).  
Some ST7 devices have two on-chip 16-bit timers.  
They are completely independent, and do not  
share any resources. They are synchronized after  
a MCU reset as long as the timer clock frequen-  
cies are not modified.  
Alternate Counter Register (ACR)  
– Alternate Counter High Register (ACHR) is the  
most significant byte (MS Byte).  
– Alternate Counter Low Register (ACLR) is the  
least significant byte (LS Byte).  
This description covers one or two 16-bit timers. In  
ST7 devices with two timers, register names are  
prefixed with TA (Timer A) or TB (Timer B).  
These two read-only 16-bit registers contain the  
same value but with the difference that reading the  
ACLR register does not clear the TOF bit (Timer  
overflow flag), located in the Status register (SR).  
(See note at the end of paragraph entitled “16-bit  
Read Sequence”).  
8.3.2 Main Features  
Programmableprescaler:fCPU dividedby2,4or8.  
Overflow status flag and maskable interrupt  
External clock input (must be at least 4 times  
slowerthantheCPUclockspeed)withthechoice  
of active edge  
Writing in the CLR register or ACLR register resets  
the free running counter to the FFFCh value.  
Both counters have a reset value of FFFCh (this is  
the only value which is reloaded in the 16-bit tim-  
er). The reset value of both counters is also  
FFFCh in One Pulse mode and PWM mode.  
Output compare functions with:  
– 2 dedicated 16-bit registers  
– 2 dedicated programmable signals  
– 2 dedicated status flags  
The timer clock depends on the clock control bits  
of the CR2 register, as illustrated in Table 40 Clock  
Control Bits. The value in the counter register re-  
peats every 131072, 262144 or 524288 CPU clock  
cycles depending on the CC[1:0] bits.  
– 1 dedicated maskable interrupt  
Input capture functions with:  
– 2 dedicated 16-bit registers  
– 2 dedicated active edge selection signals  
– 2 dedicated status flags  
The timer frequency can be f  
or an external frequency.  
/2, f  
/4, f  
/8  
CPU  
CPU  
CPU  
– 1 dedicated maskable interrupt  
Pulse Width Modulation mode (PWM)  
One Pulse mode  
5 alternate functions on I/O ports (ICAP1, ICAP2,  
OCMP1, OCMP2, EXTCLK)*  
The Block Diagram is shown in Figure 44.  
*Note: Some timer pins may not be available (not  
bonded) in some ST7 devices. Refer to the device  
pinout description. When reading an input signal  
on a non-bonded pin, the value will always be ‘1’.  
77/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
Figure 44. Timer Block Diagram  
ST7 INTERNAL BUS  
f
CPU  
MCU-PERIPHERAL INTERFACE  
8 low  
8-bit  
8 high  
8
8
8
8
8
8
8
8
buffer  
EXEDG  
16  
INPUT  
CAPTURE  
REGISTER  
INPUT  
CAPTURE  
REGISTER  
OUTPUT  
COMPARE  
REGISTER  
OUTPUT  
COMPARE  
REGISTER  
1/2  
1/4  
1/8  
COUNTER  
REGISTER  
1
1
2
2
ALTERNATE  
COUNTER  
REGISTER  
EXTCLK  
pin  
16  
16  
16  
CC[1:0]  
TIMER INTERNAL BUS  
16 16  
OVERFLOW  
DETECT  
EDGE DETECT  
CIRCUIT1  
OUTPUT COMPARE  
CIRCUIT  
ICAP1  
pin  
CIRCUIT  
6
EDGE DETECT  
CIRCUIT2  
ICAP2  
pin  
OCMP1  
pin  
LATCH1  
LATCH2  
ICF1 OCF1 TOF ICF2 OCF2  
0
0
0
OCMP2  
pin  
(Status Register) SR  
EXEDG  
ICIE OCIE TOIE FOLV2 FOLV1OLVL2 IEDG1 OLVL1  
OC1E  
OPM PWM CC1 CC0 IEDG2  
OC2E  
(Control Register 1) CR1  
(Control Register 2) CR2  
(See note)  
Note: If IC, OC and TO interrupt requests have separate vectors  
then the last OR is not present (see device Interrupt Vector table).  
TIMER INTERRUPT  
78/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
16-bit Read Sequence: (from either the Counter  
Register or the Alternate Counter Register).  
Clearing the overflow interrupt request is done in  
two steps:  
1. Reading the SR register while the TOF bit is set.  
2. An access (read or write) to the CLR register.  
Beginning of the sequence  
Read  
LS Byte  
Note: The TOF bit is not cleared by accessing the  
ACLR register. The advantage of accessing the  
ACLR register rather than the CLR register is that  
it allows simultaneous use of the overflow function  
and reading the free running counter at random  
times (for example, to measure elapsed time) with-  
out the risk of clearing the TOF bit erroneously.  
MS Byte  
At t0  
is buffered  
Other  
instructions  
Returns the buffered  
LS Byte value at t0  
Read  
LS Byte  
At t0 +t  
The timer is not affected by WAIT mode.  
In HALT mode, the counter stops counting until the  
mode is exited. Counting then resumes from the  
previous count (MCU awakened by an interrupt) or  
from the reset count (MCU awakened by a Reset).  
Sequence completed  
The user must read the MS Byte first, then the LS  
Byte value is buffered automatically.  
This buffered value remains unchanged until the  
16-bit read sequence is completed, even if the  
user reads the MS Byte several times.  
8.3.3.2 External Clock  
The external clock (where available) is selected if  
CC0 = 1 and CC1 = 1 in the CR2 register.  
After a complete reading sequence, if only the  
CLR register or ACLR register are read, they re-  
turn the LS Byte of the count value at the time of  
the read.  
The status of the EXEDG bit in the CR2 register  
determines the type of level transition on the exter-  
nal clock pin EXTCLK that will trigger the free run-  
ning counter.  
Whatever the timer mode used (input capture, out-  
put compare, One Pulse mode or PWM mode) an  
overflow occurs when the counter rolls over from  
FFFFh to 0000h then:  
The counter is synchronized with the falling edge  
of the internal CPU clock.  
A minimum of four falling edges of the CPU clock  
must occur between two consecutive active edges  
of the external clock; thus the external clock fre-  
quency must be less than a quarter of the CPU  
clock frequency.  
– The TOF bit of the SR register is set.  
– A timer interrupt is generated if:  
– TOIE bit of the CR1 register is set and  
– I bit of the CC register is cleared.  
If one of these conditions is false, the interrupt re-  
mains pending to be issued as soon as they are  
both true.  
79/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
Figure 45. Counter Timing Diagram, internal clock divided by 2  
CPU CLOCK  
INTERNAL RESET  
TIMER CLOCK  
FFFD FFFE FFFF 0000 0001 0002 0003  
COUNTER REGISTER  
TIMER OVERFLOW FLAG (TOF)  
Figure 46. Counter Timing Diagram, internal clock divided by 4  
CPU CLOCK  
INTERNAL RESET  
TIMER CLOCK  
FFFC  
FFFD  
0000  
0001  
COUNTER REGISTER  
TIMER OVERFLOW FLAG (TOF)  
Figure 47. Counter Timing Diagram, internal clock divided by 8  
CPU CLOCK  
INTERNAL RESET  
TIMER CLOCK  
0000  
FFFC  
FFFD  
COUNTER REGISTER  
TIMER OVERFLOW FLAG (TOF)  
Note: The MCU is in reset state when the internal reset signal is high. When it is low, the MCU is running.  
80/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
8.3.3.3 Input Capture  
When an input capture occurs:  
In this section, the index, i, may be 1 or 2 because  
there are two input capture functions in the 16-bit  
timer.  
– The ICFi bit is set.  
– The ICiR register contains the value of the free  
running counter on the active transition on the  
ICAPi pin (see Figure 49).  
The two input capture 16-bit registers (IC1R and  
IC2R) are used to latch the value of the free run-  
ning counter after a transition is detected by the  
ICAPi pin (see Figure 48).  
– A timer interrupt is generated if the ICIE bit is set  
and the I bit is cleared in the CC register. Other-  
wise, the interrupt remains pending until both  
conditions become true.  
MS Byte  
LS Byte  
ICiR  
ICiHR  
ICiLR  
Clearing the Input Capture interrupt request (i.e.  
clearing the ICFi bit) is done in two steps:  
The ICiR register is a read-only register.  
1. Reading the SR register while the ICFi bit is set.  
2. An access (read or write) to the ICiLR register.  
The active transition is software programmable  
through the IEDGi bit of Control Registers (CRi).  
Timing resolution is one count of the free running  
Notes:  
counter: (f  
/CC[1:0]).  
CPU  
1. After reading the ICiHR register, the transfer of  
input capture data is inhibited and ICFi will  
never be set until the ICiLR register is also  
read.  
Procedure:  
To use the input capture function, select the fol-  
lowing in the CR2 register:  
2. The ICiR register contains the free running  
counter value which corresponds to the most  
recent input capture.  
– Select the timer clock (CC[1:0]) (see Table 40  
Clock Control Bits).  
3. The two input capture functions can be used  
together even if the timer also uses the two out-  
put compare functions.  
– Select the edge of the active transition on the  
ICAP2 pin with the IEDG2 bit (the ICAP2 pin  
must be configured as a floating input or input  
with pull-up without interrupt if this configuration  
is available).  
4. In One Pulse mode and PWM mode only the  
input capture 2 function can be used.  
And select the following in the CR1 register:  
5. The alternate inputs (ICAP1 and ICAP2) are  
always directly connected to the timer. So any  
transitions on these pins activate the input cap-  
ture function.  
– Set the ICIE bit to generate an interrupt after an  
input capture coming from either the ICAP1 pin  
or the ICAP2 pin  
Moreover if one of the ICAPi pin is configured  
as an input and the second one as an output,  
an interrupt can be generated if the user tog-  
gles the output pin and if the ICIE bit is set.  
This can be avoided if the input capture func-  
tion i is disabled by reading the ICiHR (see note  
1).  
– Select the edge of the active transition on the  
ICAP1 pin with the IEDG1 bit (the ICAP1 pin  
must be configured as a floating input or input  
with pull-up without interrupt if this configuration  
is available).  
6. The TOF bit can be used with an interrupt in  
order to measure events that exceed the timer  
range (FFFFh).  
81/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
Figure 48. Input Capture Block Diagram  
ICAP1  
pin  
(Control Register 1) CR1  
EDGE DETECT  
CIRCUIT2  
EDGE DETECT  
CIRCUIT1  
ICIE  
IEDG1  
ICAP2  
pin  
(Status Register) SR  
ICF1  
ICF2  
0
0
0
IC2R Register  
IC1R Register  
(Control Register 2) CR2  
16-BIT  
16-BIT FREE RUNNING  
COUNTER  
IEDG2  
CC0  
CC1  
Figure 49. Input Capture Timing Diagram  
TIMER CLOCK  
FF01  
FF02  
FF03  
COUNTER REGISTER  
ICAPi PIN  
ICAPi FLAG  
FF03  
ICAPi REGISTER  
Note: Active edge is rising edge.  
82/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
8.3.3.4 Output Compare  
– The OCMPi pin takes OLVLi bit value (OCMPi  
pin latch is forced low during reset).  
In this section, the index, i, may be 1 or 2 because  
there are two output compare functions in the 16-  
bit timer.  
– A timer interrupt is generated if the OCIE bit is  
set in the CR1 register and the I bit is cleared in  
the CC register (CC).  
This function can be used to control an output  
waveform or indicate when a period of time has  
elapsed.  
The OCiR register value required for a specific tim-  
ing application can be calculated using the follow-  
ing formula:  
When a match is found between the Output Com-  
pare register and the free running counter, the out-  
put compare function:  
– Assigns pins with a programmable value if the  
t f  
* CPU  
PRESC  
OCiR =  
OCiE bit is set  
– Sets a flag in the status register  
– Generates an interrupt if enabled  
Where:  
t  
= Output compare period (in seconds)  
= CPU clock frequency (in hertz)  
Two 16-bit registers Output Compare Register 1  
(OC1R) and Output Compare Register 2 (OC2R)  
contain the value to be compared to the counter  
register each timer clock cycle.  
f
CPU  
= Timer prescaler factor (2, 4 or 8 de-  
pending on CC[1:0] bits, see Table 40  
Clock Control Bits)  
PRESC  
MS Byte  
LS Byte  
OCiR  
OCiHR  
OCiLR  
If the timer clock is an external clock, the formula  
is:  
These registers are readable and writable and are  
not affected by the timer hardware. A reset event  
changes the OCiR value to 8000h.  
OCiR = t f  
* EXT  
Timing resolution is one count of the free running  
Where:  
counter: (f  
).  
CC[1:0]  
CPU/  
t  
= Output compare period (in seconds)  
= External timer clock frequency (in hertz)  
f
EXT  
Procedure:  
To use the output compare function, select the fol-  
lowing in the CR2 register:  
Clearing the output compare interrupt request (i.e.  
clearing the OCFi bit) is done by:  
– Set the OCiE bit if an output is needed then the  
OCMPi pin is dedicated to the output compare i  
signal.  
1. Reading the SR register while the OCFi bit is  
set.  
2. An access (read or write) to the OCiLR register.  
– Select the timer clock (CC[1:0]) (see Table 40  
Clock Control Bits).  
The following procedure is recommended to pre-  
vent the OCFi bit from being set between the time  
it is read and the write to the OCiR register:  
And select the following in the CR1 register:  
– Select the OLVLi bit to applied to the OCMPi pins  
after the match occurs.  
– Write to the OCiHR register (further compares  
are inhibited).  
– Set the OCIE bit to generate an interrupt if it is  
needed.  
– Read the SR register (first step of the clearance  
of the OCFi bit, which may be already set).  
When a match is found between OCRi register  
and CR register:  
– Write to the OCiLR register (enables the output  
compare function and clears the OCFi bit).  
– OCFi bit is set.  
83/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
Notes:  
Forced Compare Output capability  
1. After a processor write cycle to the OCiHR reg-  
ister, the output compare function is inhibited  
until the OCiLR register is also written.  
When the FOLVi bit is set by software, the OLVLi  
bit is copied to the OCMPi pin. The OLVi bit has to  
be toggled in order to toggle the OCMPi pin when  
it is enabled (OCiE bit = 1). The OCFi bit is then  
not set by hardware, and thus no interrupt request  
is generated.  
2. If the OCiE bit is not set, the OCMPi pin is a  
general I/O port and the OLVLi bit will not  
appear when a match is found but an interrupt  
could be generated if the OCIE bit is set.  
FOLVLi bits have no effect in either One-Pulse  
mode or PWM mode.  
3. When the timer clock is f  
/2, OCFi and  
CPU  
OCMPi are set while the counter value equals  
the OCiR register value (see Figure 51). This  
behavior is the same in OPM or PWM mode.  
When the timer clock is f  
/4, f  
/8 or in  
CPU  
CPU  
external clock mode, OCFi and OCMPi are set  
while the counter value equals the OCiR regis-  
ter value plus 1 (see Figure 52).  
4. The output compare functions can be used both  
for generating external events on the OCMPi  
pins even if the input capture mode is also  
used.  
5. The value in the 16-bit OCiR register and the  
OLVi bit should be changed after each suc-  
cessful comparison in order to control an output  
waveform or establish a new elapsed timeout.  
Figure 50. Output Compare Block Diagram  
16 BIT FREE RUNNING  
OC1E  
CC1 CC0  
OC2E  
COUNTER  
(Control Register 2) CR2  
16-bit  
(Control Register 1) CR1  
OUTPUT COMPARE  
CIRCUIT  
Latch  
1
OCIE  
FOLV2 FOLV1 OLVL2  
OLVL1  
OCMP1  
Pin  
16-bit  
16-bit  
Latch  
2
OCMP2  
Pin  
OC1R Register  
OCF1  
OCF2  
0
0
0
OC2R Register  
(Status Register) SR  
84/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
Figure 51. Output Compare Timing Diagram, f  
= f  
/2  
TIMER  
CPU  
INTERNAL CPU CLOCK  
TIMER CLOCK  
COUNTER REGISTER  
2ECF 2ED0 2ED1 2ED2  
2ED3  
2ED4  
2ED3  
OUTPUT COMPARE REGISTER i (OCRi)  
OUTPUT COMPARE FLAG i (OCFi)  
OCMPi PIN (OLVLi = 1)  
Figure 52. Output Compare Timing Diagram, f  
= f  
/4  
TIMER  
CPU  
INTERNAL CPU CLOCK  
TIMER CLOCK  
2ECF 2ED0 2ED1 2ED2  
2ED3  
2ED4  
2ED3  
COUNTER REGISTER  
OUTPUT COMPARE REGISTER i (OCRi)  
COMPARE REGISTER i LATCH  
OUTPUT COMPARE FLAG i (OCFi)  
OCMPi PIN (OLVLi = 1)  
85/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
8.3.3.5 One Pulse Mode  
Clearing the Input Capture interrupt request (i.e.  
clearing the ICFi bit) is done in two steps:  
One Pulse mode enables the generation of a  
pulse when an external event occurs. This mode is  
selected via the OPM bit in the CR2 register.  
1. Reading the SR register while the ICFi bit is set.  
2. An access (read or write) to the ICiLR register.  
The One Pulse mode uses the Input Capture1  
function and the Output Compare1 function.  
The OC1R register value required for a specific  
timing application can be calculated using the fol-  
lowing formula:  
Procedure:  
t * f  
To use One Pulse mode:  
CPU  
- 5  
OCiR Value =  
1. Load the OC1R register with the value corre-  
sponding to the length of the pulse (see the for-  
mula in the opposite column).  
PRESC  
Where:  
t
= Pulse period (in seconds)  
2. Select the following in the CR1 register:  
f
= CPU clock frequency (in hertz)  
CPU  
– Using the OLVL1 bit, select the level to be ap-  
plied to the OCMP1 pin after the pulse.  
= Timer prescaler factor (2, 4 or 8 depend-  
ing on the CC[1:0] bits, see Table 40  
Clock Control Bits)  
PRESC  
– Using the OLVL2 bit, select the level to be ap-  
plied to the OCMP1 pin during the pulse.  
If the timer clock is an external clock the formula is:  
– Select the edge of the active transition on the  
ICAP1 pin with the IEDG1 bit (the ICAP1 pin  
must be configured as floating input).  
OCiR = t f  
-5  
* EXT  
Where:  
t
3. Select the following in the CR2 register:  
= Pulse period (in seconds)  
– Set the OC1E bit, the OCMP1 pin is then dedi-  
cated to the Output Compare 1 function.  
f
= External timer clock frequency (in hertz)  
EXT  
– Set the OPM bit.  
When the value of the counter is equal to the value  
of the contents of the OC1R register, the OLVL1  
bit is output on the OCMP1 pin (see Figure 53).  
– Select the timer clock CC[1:0] (see Table 40  
Clock Control Bits).  
One Pulse mode cycle  
Notes:  
1. The OCF1 bit cannot be set by hardware in  
One Pulse mode but the OCF2 bit can generate  
an Output Compare interrupt.  
When  
OCMP1 = OLVL2  
event occurs  
on ICAP1  
Counter is reset  
2. When the Pulse Width Modulation (PWM) and  
One Pulse mode (OPM) bits are both set, the  
PWM mode is the only active one.  
to FFFCh  
ICF1 bit is set  
3. If OLVL1 = OLVL2 a continuous signal will be  
seen on the OCMP1 pin.  
When  
Counter  
OCMP1 = OLVL1  
= OC1R  
4. The ICAP1 pin cannot be used to perform input  
capture. The ICAP2 pin can be used to perform  
input capture (ICF2 can be set and IC2R can be  
loaded) but the user must take care that the  
counter is reset each time a valid edge occurs  
on the ICAP1 pin and ICF1 can also generates  
interrupt if ICIE is set.  
Then, on a valid event on the ICAP1 pin, the coun-  
ter is initialized to FFFCh and the OLVL2 bit is  
loaded on the OCMP1 pin, the ICF1 bit is set and  
the value FFFDh is loaded in the IC1R register.  
Because the ICF1 bit is set when an active edge  
occurs, an interrupt can be generated if the ICIE  
bit is set.  
5. When One Pulse mode is used OC1R is dedi-  
cated to this mode. Nevertheless OC2R and  
OCF2 can be used to indicate that a period of  
time has elapsed but cannot generate an output  
waveform because the OLVL2 level is dedi-  
cated to One Pulse mode.  
86/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
Figure 53. One Pulse Mode Timing Example  
FFFC FFFD FFFE  
COUNTER  
2ED0 2ED1 2ED2  
2ED3  
FFFC FFFD  
ICAP1  
OLVL2  
OLVL1  
OLVL2  
OCMP1  
compare1  
Note: IEDG1 = 1, OC1R = 2ED0h, OLVL1 = 0, OLVL2 = 1  
Figure 54. Pulse Width Modulation Mode Timing Example  
2ED0 2ED1 2ED2  
34E2 FFFC  
FFFC FFFD FFFE  
34E2  
COUNTER  
OCMP1  
OLVL2  
OLVL1  
OLVL2  
compare2  
compare1  
compare2  
Note: OC1R = 2ED0h, OC2R = 34E2, OLVL1 = 0, OLVL2 = 1  
87/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
8.3.3.6 Pulse Width Modulation Mode  
Pulse Width Modulation (PWM) mode enables the  
generation of a signal with a frequency and pulse  
length determined by the value of the OC1R and  
OC2R registers.  
The OCiR register value required for a specific tim-  
ing application can be calculated using the follow-  
ing formula:  
t * f  
CPU  
PRESC  
- 5  
OCiR Value =  
The Pulse Width Modulation mode uses the com-  
plete Output Compare 1 function plus the OC2R  
register, and so these functions cannot be used  
when the PWM mode is activated.  
Where:  
t
= Signal or pulse period (in seconds)  
= CPU clock frequency (in hertz)  
f
Procedure  
CPU  
= Timer prescaler factor (2, 4 or 8 depend-  
ing on CC[1:0] bits; see Table 40 Clock  
Control Bits)  
To use Pulse Width Modulation mode:  
PRESC  
1. Load the OC2R register with the value corre-  
sponding to the period of the signal using the  
formula in the opposite column.  
If the timer clock is an external clock the formula is:  
2. Load the OC1R register with the value corre-  
sponding to the period of the pulse if OLVL1 = 0  
and OLVL2 = 1, using the formula in the oppo-  
site column.  
OCiR = t f  
-5  
* EXT  
Where:  
t
= Signal or pulse period (in seconds)  
3. Select the following in the CR1 register:  
f
= External timer clock frequency (in hertz)  
EXT  
– Using the OLVL1 bit, select the level to be ap-  
plied to the OCMP1 pin after a successful com-  
parison with OC1R register.  
The Output Compare 2 event causes the counter  
to be initialized to FFFCh (see Figure 54).  
– Using the OLVL2 bit, select the level to be ap-  
plied to the OCMP1 pin after a successful com-  
parison with OC2R register.  
Notes:  
1. After a write instruction to the OCiHR register,  
the output compare function is inhibited until the  
OCiLR register is also written.  
4. Select the following in the CR2 register:  
– Set OC1E bit: the OCMP1 pin is then dedicated  
to the output compare 1 function.  
2. The OCF1 and OCF2 bits cannot be set by  
hardware in PWM mode, therefore the Output  
Compare interrupt is inhibited.  
– Set the PWM bit.  
– Select the timer clock (CC[1:0]) (see Table 40  
Clock Control Bits).  
3. The ICF1 bit is set by hardware when the coun-  
ter reaches the OC2R value and can produce a  
timer interrupt if the ICIE bit is set and the I bit is  
cleared.  
If OLVL1 = 1 and OLVL2 = 0, the length of the  
positive pulse is the difference between the OC2R  
and OC1R registers.  
4. In PWM mode the ICAP1 pin cannot be used to  
perform input capture because it is discon-  
nected from the timer. The ICAP2 pin can be  
used to perform input capture (ICF2 can be set  
and IC2R can be loaded) but the user must  
take care that the counter is reset after each  
period and ICF1 can also generate an interrupt  
if ICIE is set.  
If OLVL1 = OLVL2 a continuous signal will be  
seen on the OCMP1 pin.  
Pulse Width Modulation cycle  
When  
Counter  
= OC1R  
OCMP1 = OLVL1  
5. When the Pulse Width Modulation (PWM) and  
One Pulse mode (OPM) bits are both set, the  
PWM mode is the only active one.  
OCMP1 = OLVL2  
When  
Counter  
= OC2R  
Counter is reset  
to FFFCh  
ICF1 bit is set  
88/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
8.3.4 Low Power Modes  
Mode  
Description  
No effect on 16-bit Timer.  
WAIT  
HALT  
Timer interrupts cause the device to exit from WAIT mode.  
16-bit Timer registers are frozen.  
In HALT mode, the counter stops counting until Halt mode is exited. Counting resumes from the previous  
count when the MCU is woken up by an interrupt with “exit from HALT mode” capability or from the counter  
reset value when the MCU is woken up by a RESET.  
If an input capture event occurs on the ICAPi pin, the input capture detection circuitry is armed. Consequent-  
ly, when the MCU is woken up by an interrupt with “exit from HALT mode” capability, the ICFi bit is set, and  
the counter value present when exiting from HALT mode is captured into the ICiR register.  
8.3.5 Interrupts  
Enable  
Control from  
Bit  
Exit  
Exit  
from  
Halt  
Event  
Flag  
Interrupt Event  
Wait  
Yes  
Yes  
Yes  
Yes  
Yes  
Input Capture 1 event/Counter reset in PWM mode  
Input Capture 2 event  
ICF1  
ICF2  
No  
No  
No  
No  
No  
ICIE  
Output Compare 1 event (not available in PWM mode)  
Output Compare 2 event (not available in PWM mode)  
Timer Overflow event  
OCF1  
OCF2  
TOF  
OCIE  
TOIE  
Note: The 16-bit Timer interrupt events are connected to the same interrupt vector (see Interrupts chap-  
ter). These events generate an interrupt if the corresponding Enable Control Bit is set and the interrupt  
mask in the CC register is reset (RIM instruction).  
8.3.6 Summary of Timer modes  
AVAILABLE RESOURCES  
MODES  
Input Capture 1  
Input Capture 2  
Yes  
Output Compare 1 Output Compare 2  
Input Capture (1 and/or 2)  
Output Compare (1 and/or 2)  
One Pulse mode  
Yes  
Yes  
No  
Yes  
Yes  
No  
Yes  
Yes  
Yes  
1)  
3)  
2)  
Not Recommended  
Not Recommended  
Partially  
No  
PWM Mode  
No  
No  
Notes:  
1. See note 4 in Section 8.3.3.5 One Pulse Mode  
2. See note 5 in Section 8.3.3.5 One Pulse Mode  
3. See note 4 in Section 8.3.3.6 Pulse Width Modulation Mode  
89/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
8.3.7 Register Description  
Bit 4 = FOLV2 Forced Output Compare 2.  
This bit is set and cleared by software.  
0: No effect on the OCMP2 pin.  
1:Forces the OLVL2 bit to be copied to the  
OCMP2 pin, if the OC2E bit is set and even if  
there is no successful comparison.  
Each Timer is associated with 3 control and status  
registers, and with 6 pairs of data registers (16-bit  
values) relating to the 2 input captures, the 2 out-  
put compares, the counter and the alternate coun-  
ter.  
Bit 3 = FOLV1 Forced Output Compare 1.  
This bit is set and cleared by software.  
0: No effect on the OCMP1 pin.  
CONTROL REGISTER 1 (CR1)  
Read/Write  
1: Forces OLVL1 to be copied to the OCMP1 pin, if  
the OC1E bit is set and even if there is no suc-  
cessful comparison.  
Reset Value: 0000 0000 (00h)  
7
0
ICIE OCIE TOIE FOLV2 FOLV1 OLVL2 IEDG1 OLVL1  
Bit 2 = OLVL2 Output Level 2.  
This bit is copied to the OCMP2 pin whenever a  
successful comparison occurs with the OC2R reg-  
ister and OCxE is set in the CR2 register. This val-  
ue is copied to the OCMP1 pin in One Pulse mode  
and Pulse Width Modulation mode.  
Bit 7 = ICIE Input Capture Interrupt Enable.  
0: Interrupt is inhibited.  
1: A timer interrupt is generated whenever the  
ICF1 or ICF2 bit of the SR register is set.  
Bit 1 = IEDG1 Input Edge 1.  
Bit 6 = OCIE Output Compare Interrupt Enable.  
0: Interrupt is inhibited.  
1: A timer interrupt is generated whenever the  
OCF1 or OCF2 bit of the SR register is set.  
This bit determines which type of level transition  
on the ICAP1 pin will trigger the capture.  
0: A falling edge triggers the capture.  
1: A rising edge triggers the capture.  
Bit 5 = TOIE Timer Overflow Interrupt Enable.  
0: Interrupt is inhibited.  
1: A timer interrupt is enabled whenever the TOF  
bit of the SR register is set.  
Bit 0 = OLVL1 Output Level 1.  
The OLVL1 bit is copied to the OCMP1 pin when-  
ever a successful comparison occurs with the  
OC1R register and the OC1E bit is set in the CR2  
register.  
90/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
CONTROL REGISTER 2 (CR2)  
Read/Write  
Bit 4 = PWM Pulse Width Modulation.  
0: PWM mode is not active.  
1: PWM mode is active, the OCMP1 pin outputs a  
programmable cyclic signal; the length of the  
pulse depends on the value of OC1R register;  
the period depends on the value of OC2R regis-  
ter.  
Reset Value: 0000 0000 (00h)  
7
0
OC1E OC2E OPM PWM CC1 CC0 IEDG2 EXEDG  
Bits 3:2 = CC[1:0] Clock Control.  
Bit 7 = OC1E Output Compare 1 Pin Enable.  
This bit is used only to output the signal from the  
timer on the OCMP1 pin (OLV1 in Output Com-  
pare mode, both OLV1 and OLV2 in PWM and  
one-pulse mode). Whatever the value of the OC1E  
bit, the internal Output Compare 1 function of the  
timer remains active.  
0: OCMP1 pin alternate function disabled (I/O pin  
free for general-purpose I/O).  
1: OCMP1 pin alternate function enabled.  
The timer clock mode depends on these bits:  
Table 40. Clock Control Bits  
Timer Clock  
fCPU / 4  
CC1  
CC0  
0
0
1
0
1
0
fCPU / 2  
fCPU / 8  
External Clock (where  
available)  
1
1
Bit 6 = OC2E Output Compare 2 Pin Enable.  
This bit is used only to output the signal from the  
timer on the OCMP2 pin (OLV2 in Output Com-  
pare mode). Whatever the value of the OC2E bit,  
the internal Output Compare 2 function of the timer  
remains active.  
0: OCMP2 pin alternate function disabled (I/O pin  
free for general-purpose I/O).  
1: OCMP2 pin alternate function enabled.  
Note: If the external clock pin is not available, pro-  
gramming the external clock configuration stops  
the counter.  
Bit 1 = IEDG2 Input Edge 2.  
This bit determines which type of level transition  
on the ICAP2 pin will trigger the capture.  
0: A falling edge triggers the capture.  
1: A rising edge triggers the capture.  
Bit 5 = OPM One Pulse mode.  
0: One Pulse mode is not active.  
1: One Pulse mode is active, the ICAP1 pin can be  
used to trigger one pulse on the OCMP1 pin; the  
active transition is given by the IEDG1 bit. The  
length of the generated pulse depends on the  
contents of the OC1R register.  
Bit 0 = EXEDG External Clock Edge.  
This bit determines which type of level transition  
on the external clock pin (EXTCLK) will trigger the  
counter register.  
0: A falling edge triggers the counter register.  
1: A rising edge triggers the counter register.  
91/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
STATUS REGISTER (SR)  
Read Only  
INPUT CAPTURE 1 HIGH REGISTER (IC1HR)  
Read Only  
Reset Value: Undefined  
Reset Value: 0000 0000 (00h)  
The three least significant bits are not used.  
7
This is an 8-bit read only register that contains the  
high part of the counter value (transferred by the  
input capture 1 event).  
0
0
ICF1 OCF1 TOF ICF2 OCF2  
0
0
7
0
MSB  
LSB  
Bit 7 = ICF1 Input Capture Flag 1.  
0: No input capture (reset value).  
1: An input capture has occurred on the ICAP1 pin  
or the counter has reached the OC2R value in  
PWM mode. To clear this bit, first read the SR  
register, then read or write the low byte of the  
IC1R (IC1LR) register.  
INPUT CAPTURE 1 LOW REGISTER (IC1LR)  
Read Only  
Reset Value: Undefined  
This is an 8-bit read only register that contains the  
low part of the counter value (transferred by the in-  
put capture 1 event).  
Bit 6 = OCF1 Output Compare Flag 1.  
0: No match (reset value).  
1: The content of the free running counter matches  
the content of the OC1R register. To clear this  
bit, first read the SR register, then read or write  
the low byte of the OC1R (OC1LR) register.  
7
0
MSB  
LSB  
Bit 5 = TOF Timer Overflow Flag.  
OUTPUT COMPARE  
(OC1HR)  
1
HIGH REGISTER  
0: No timer overflow (reset value).  
1:The free running counter has rolled over from  
FFFFh to 0000h. To clear this bit, first read the  
SR register, then read or write the low byte of  
the CR (CLR) register.  
Read/Write  
Reset Value: 1000 0000 (80h)  
This is an 8-bit register that contains the high part  
of the value to be compared to the CHR register.  
Note: Reading or writing the ACLR register does  
not clear TOF.  
7
0
MSB  
LSB  
Bit 4 = ICF2 Input Capture Flag 2.  
0: No input capture (reset value).  
1: An input capture has occurred on the ICAP2  
pin. To clear this bit, first read the SR register,  
then read or write the low byte of the IC2R  
(IC2LR) register.  
OUTPUT COMPARE  
(OC1LR)  
1
LOW REGISTER  
Read/Write  
Reset Value: 0000 0000 (00h)  
Bit 3 = OCF2 Output Compare Flag 2.  
0: No match (reset value).  
This is an 8-bit register that contains the low part of  
the value to be compared to the CLR register.  
1: The content of the free running counter matches  
the content of the OC2R register. To clear this  
bit, first read the SR register, then read or write  
the low byte of the OC2R (OC2LR) register.  
7
0
MSB  
LSB  
Bit 2-0 = Reserved, forced by hardware to 0.  
92/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
OUTPUT COMPARE  
(OC2HR)  
2
HIGH REGISTER  
ALTERNATE COUNTER HIGH REGISTER  
(ACHR)  
Read/Write  
Reset Value: 1000 0000 (80h)  
Read Only  
Reset Value: 1111 1111 (FFh)  
This is an 8-bit register that contains the high part  
of the value to be compared to the CHR register.  
This is an 8-bit register that contains the high part  
of the counter value.  
7
0
7
0
MSB  
LSB  
MSB  
LSB  
OUTPUT COMPARE  
(OC2LR)  
2
LOW REGISTER  
ALTERNATE COUNTER LOW REGISTER  
(ACLR)  
Read/Write  
Reset Value: 0000 0000 (00h)  
Read Only  
Reset Value: 1111 1100 (FCh)  
This is an 8-bit register that contains the low part of  
the value to be compared to the CLR register.  
This is an 8-bit register that contains the low part of  
the counter value. A write to this register resets the  
counter. An access to this register after an access  
to SR register does not clear the TOF bit in SR  
register.  
7
0
MSB  
LSB  
7
0
COUNTER HIGH REGISTER (CHR)  
MSB  
LSB  
Read Only  
Reset Value: 1111 1111 (FFh)  
INPUT CAPTURE 2 HIGH REGISTER (IC2HR)  
This is an 8-bit register that contains the high part  
of the counter value.  
Read Only  
Reset Value: Undefined  
7
0
This is an 8-bit read only register that contains the  
high part of the counter value (transferred by the  
Input Capture 2 event).  
MSB  
LSB  
7
0
MSB  
LSB  
COUNTER LOW REGISTER (CLR)  
Read Only  
Reset Value: 1111 1100 (FCh)  
This is an 8-bit register that contains the low part of  
the counter value. A write to this register resets the  
counter. An access to this register after accessing  
the SR register clears the TOF bit.  
INPUT CAPTURE 2 LOW REGISTER (IC2LR)  
Read Only  
Reset Value: Undefined  
This is an 8-bit read only register that contains the  
low part of the counter value (transferred by the In-  
put Capture 2 event).  
7
0
MSB  
LSB  
7
0
MSB  
LSB  
93/131  
ST72141K2-Auto  
16-BIT TIMER (Cont’d)  
Table 41. 16-Bit Timer Register Map and Reset Values  
Address  
(Hex.)  
Register  
Label  
7
6
5
4
3
2
1
0
Timer A: 32 CR1  
ICIE  
0
OCIE  
0
TOIE  
0
FOLV2  
0
FOLV1  
0
OLVL2  
0
IEDG1  
0
OLVL1  
0
Timer B: 42 Reset Value  
Timer A: 31 CR2  
OC1E  
0
OC2E  
0
OPM  
0
PWM  
0
CC1  
0
CC0  
0
IEDG2  
0
EXEDG  
0
Timer B: 41 Reset Value  
Timer A: 33 SR  
ICF1  
0
OCF1  
0
TOF  
0
ICF2  
0
OCF2  
0
-
-
-
Timer B: 43 Reset Value  
0
0
0
Timer A: 34 ICHR1  
MSB  
-
LSB  
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Timer B: 44 Reset Value  
Timer A: 35 ICLR1  
MSB  
-
LSB  
-
Timer B: 45 Reset Value  
Timer A: 36 OCHR1  
MSB  
-
LSB  
-
Timer B: 46 Reset Value  
Timer A: 37 OCLR1  
MSB  
-
LSB  
-
Timer B: 47 Reset Value  
Timer A: 3E OCHR2  
MSB  
-
LSB  
-
Timer B: 4E Reset Value  
Timer A: 3F OCLR2  
MSB  
-
LSB  
-
Timer B: 4F Reset Value  
Timer A: 38 CHR  
MSB  
1
LSB  
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
Timer B: 48 Reset Value  
Timer A: 39 CLR  
MSB  
1
LSB  
0
Timer B: 49 Reset Value  
Timer A: 3A ACHR  
MSB  
1
LSB  
1
Timer B: 4A Reset Value  
Timer A: 3B ACLR  
MSB  
1
LSB  
0
1
-
1
-
1
-
1
-
1
-
0
-
Timer B: 4B Reset Value  
Timer A: 3C ICHR2  
MSB  
-
LSB  
-
Timer B: 4C Reset Value  
Timer A: 3D ICLR2  
MSB  
-
LSB  
-
-
-
-
-
-
-
Timer B: 4D Reset Value  
94/131  
ST72141K2-Auto  
8.4 SERIAL PERIPHERAL INTERFACE (SPI)  
8.4.1 Introduction  
8.4.3 General description  
The Serial Peripheral Interface (SPI) allows full-  
duplex, synchronous, serial communication with  
external devices. An SPI system may consist of a  
master and one or more slaves or a system in  
which devices may be either masters or slaves.  
The SPI is connected to external devices through  
four alternate pins:  
– MISO: Master In Slave Out pin  
– MOSI: Master Out Slave In pin  
– SCK: Serial Clock pin  
The SPI is normally used for communication be-  
tween the microcontroller and external peripherals  
or another microcontroller.  
– SS: Slave select pin  
A basic example of interconnections between a  
single master and a single slave is illustrated on  
Figure 55.  
Refer to Section 1.2 PIN DESCRIPTION for the  
device-specific pinout.  
The MOSI pins are connected together as are  
MISO pins. In this way data is transferred serially  
between master and slave (most significant bit  
first).  
8.4.2 Main Features  
Full duplex, three-wire synchronous transfers  
Master or slave operation  
4 master mode frequencies  
Maximum slave mode frequency = f  
4 programmable master bit rates  
When the master device transmits data to a slave  
device via MOSI pin, the slave device responds by  
sending data to the master device via the MISO  
pin. This implies full duplex transmission with both  
data out and data in synchronized with the same  
clock signal (which is provided by the master de-  
vice via the SCK pin).  
/4  
CPU  
Programmable clock polarity and phase  
End of transfer interrupt flag  
Write collision flag protection  
Master mode fault protection capability  
Thus, the byte transmitted is replaced by the byte  
received and eliminates the need for separate  
transmit-empty and receiver-full bits. A status flag  
is used to indicate that the I/O operation is com-  
plete.  
Four possible data/clock timing relationships may  
be chosen (see Figure 58) but master and slave  
must be programmed with the same timing mode.  
Figure 55. Serial Peripheral Interface Master/Slave  
MASTER  
SLAVE  
MSBit  
LSBit  
MSBit  
LSBit  
MISO  
MOSI  
MISO  
MOSI  
8-BIT SHIFT REGISTER  
8-BIT SHIFT REGISTER  
SPI  
CLOCK  
GENERATOR  
SCK  
SS  
SCK  
SS  
+5V  
95/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
Figure 56. Serial Peripheral Interface Block Diagram  
Internal Bus  
Read  
DR  
Read Buffer  
IT  
request  
MOSI  
SR  
MISO  
8-Bit Shift Register  
Write  
MODF  
WCOL  
SPIF  
-
-
-
-
-
SPI  
STATE  
CONTROL  
SCK  
SS  
CR  
SPIE SPE SPR2 MSTR CPOL CPHA SPR1 SPR0  
MASTER  
CONTROL  
SERIAL  
CLOCK  
GENERATOR  
96/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
8.4.4 Functional Description  
Figure 55 shows the serial peripheral interface  
(SPI) block diagram.  
In this configuration the MOSI pin is a data output  
and to the MISO pin is a data input.  
This interface contains three dedicated registers:  
– A Control Register (CR)  
Transmit sequence  
The transmit sequence begins when a byte is writ-  
ten the DR register.  
– A Status Register (SR)  
The data byte is parallel loaded into the 8-bit shift  
register (from the internal bus) during a write cycle  
and then shifted out serially to the MOSI pin most  
significant bit first.  
– A Data Register (DR)  
Refer to the CR, SR and DR registers in Section  
8.4.7 for the bit definitions.  
8.4.4.1 Master Configuration  
When data transfer is complete:  
– The SPIF bit is set by hardware  
In a master configuration, the serial clock is gener-  
ated on the SCK pin.  
– An interrupt is generated if the SPIE bit is set and  
the I bit in the CCR register is cleared.  
Procedure  
– Select the SPR0 & SPR1 bits to define the serial  
clock baud rate (see CR register).  
During the last clock cycle the SPIF bit is set, a  
copy of the data byte received in the shift register  
is moved to a buffer. When the DR register is read,  
the SPI peripheral returns this buffered value.  
– Select the CPOL and CPHA bits to define one of  
the four relationships between the data transfer  
and the serial clock (see Figure 58).  
Clearing the SPIF bit is performed by the following  
software sequence:  
– The SS pin must be connected to a high level  
signal during the complete byte transmit se-  
quence.  
1. An access to the SR register while the SPIF bit  
is set  
– The MSTR and SPE bits must be set (they re-  
main set only if the SS pin is connected to a high  
level signal).  
2. A read to the DR register.  
Note: While the SPIF bit is set, all writes to the DR  
register are inhibited until the SR register is read.  
97/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
8.4.4.2 Slave Configuration  
When data transfer is complete:  
– The SPIF bit is set by hardware  
In slave configuration, the serial clock is received  
on the SCK pin from the master device.  
– An interrupt is generated if SPIE bit is set and I  
bit in CCR register is cleared.  
The value of the SPR0 & SPR1 bits is not used for  
the data transfer.  
During the last clock cycle the SPIF bit is set, a  
copy of the data byte received in the shift register  
is moved to a buffer. When the DR register is read,  
the SPI peripheral returns this buffered value.  
Procedure  
– For correct data transfer, the slave device must  
be in the same timing mode as the master device  
(CPOL and CPHA bits). See Figure 58.  
Clearing the SPIF bit is performed by the following  
software sequence:  
– The SS pin must be connected to a low level sig-  
nal during the complete byte transmit sequence.  
1. An access to the SR register while the SPIF bit  
is set.  
– Clear the MSTR bit and set the SPE bit to assign  
the pins to alternate function.  
2. A read to the DR register.  
In this configuration the MOSI pin is a data input  
and the MISO pin is a data output.  
Notes: While the SPIF bit is set, all writes to the  
DR register are inhibited until the SR register is  
read.  
Transmit Sequence  
The SPIF bit can be cleared during a second  
transmission; however, it must be cleared before  
the second SPIF bit in order to prevent an overrun  
condition (see Section 8.4.4.6).  
The data byte is parallel loaded into the 8-bit shift  
register (from the internal bus) during a write cycle  
and then shifted out serially to the MISO pin most  
significant bit first.  
Depending on the CPHA bit, the SS pin has to be  
set to write to the DR register between each data  
byte transfer to avoid a write collision (see Section  
8.4.4.4).  
The transmit sequence begins when the slave de-  
vice receives the clock signal and the most signifi-  
cant bit of the data on its MOSI pin.  
98/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
8.4.4.3 Data Transfer Format  
The master device applies data to its MOSI pin-  
clock edge before the capture clock edge.  
During an SPI transfer, data is simultaneously  
transmitted (shifted out serially) and received  
(shifted in serially). The serial clock is used to syn-  
chronize the data transfer during a sequence of  
eight clock pulses.  
CPHA bit is set  
The second edge on the SCK pin (falling edge if  
the CPOL bit is reset, rising edge if the CPOL bit is  
set) is the MSBit capture strobe. Data is latched on  
the occurrence of the second clock transition.  
The SS pin allows individual selection of a slave  
device; the other slave devices that are not select-  
ed do not interfere with the SPI transfer.  
No write collision should occur even if the SS pin  
stays low during a transfer of several bytes (see  
Figure 57).  
Clock Phase and Clock Polarity  
Four possible timing relationships may be chosen  
by software, using the CPOL and CPHA bits.  
CPHA bit is reset  
The first edge on the SCK pin (falling edge if CPOL  
bit is set, rising edge if CPOL bit is reset) is the  
MSBit capture strobe. Data is latched on the oc-  
currence of the first clock transition.  
The CPOL (clock polarity) bit controls the steady  
state value of the clock when no data is being  
transferred. This bit affects both master and slave  
modes.  
The SS pin must be toggled high and low between  
each byte transmitted (see Figure 57).  
The combination between the CPOL and CPHA  
(clock phase) bits selects the data capture clock  
edge.  
To protect the transmission from a write collision a  
low value on the SS pin of a slave device freezes  
the data in its DR register and does not allow it to  
be altered. Therefore the SS pin must be high to  
write a new data byte in the DR without producing  
a write collision.  
Figure 58 shows an SPI transfer with the four com-  
binations of the CPHA and CPOL bits. The dia-  
gram may be interpreted as a master or slave tim-  
ing diagram where the SCK pin, the MISO pin and  
the MOSI pin are directly connected between the  
master and the slave device.  
The SS pin is the slave device select input and can  
be driven by the master device.  
Figure 57. CPHA / SS Timing Diagram  
Byte 3  
Byte 2  
MOSI/MISO  
Master SS  
Byte 1  
Slave SS  
(CPHA=0)  
Slave SS  
(CPHA=1)  
VR02131A  
99/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
Figure 58. Data Clock Timing Diagram  
CPHA =1  
SCLK (with  
CPOL = 1)  
SCLK (with  
CPOL = 0)  
Bit 4  
Bit 4  
Bit3  
Bit 2  
Bit 2  
Bit 1  
Bit 1  
LSBit  
LSBit  
MSBit  
MSBit  
Bit 6  
Bit 6  
Bit 5  
Bit 5  
MISO  
(from master)  
Bit3  
MOSI  
(from slave)  
SS  
(to slave)  
CAPTURE STROBE  
CPHA =0  
CPOL = 1  
CPOL = 0  
Bit 4  
Bit 4  
Bit3  
Bit 2  
Bit 2  
Bit 1  
Bit 1  
LSBit  
LSBit  
MSBit  
Bit 6  
Bit 6  
Bit 5  
Bit 5  
MISO  
(from master)  
MSBit  
Bit3  
MOSI  
(from slave)  
SS  
(to slave)  
CAPTURE STROBE  
Note: This figure should not be used as a replacement for parametric information.  
Refer to the Electrical Characteristics chapter.  
VR02131B  
100/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
8.4.4.4 Write Collision Error  
When the CPHA bit is reset:  
A write collision occurs when the software tries to  
write to the DR register while a data transfer is tak-  
ing place with an external device. When this hap-  
pens, the transfer continues uninterrupted; and  
the software write will be unsuccessful.  
Data is latched on the occurrence of the first clock  
transition. The slave device does not have any  
way of knowing when that transition will occur;  
therefore, the slave device collision occurs when  
software attempts to write the DR register after its  
SS pin has been pulled low.  
Write collisions can occur both in master and slave  
mode.  
For this reason, the SS pin must be high, between  
each data byte transfer, to allow the CPU to write  
in the DR register without generating a write colli-  
sion.  
Note: A “read collision” will never occur since the  
received data byte is placed in a buffer in which  
access is always synchronous with the MCU oper-  
ation.  
In Master mode  
In Slave mode  
Collision in the master device is defined as a write  
of the DR register while the internal serial clock  
(SCK) is in the process of transfer.  
When the CPHA bit is set:  
The slave device will receive a clock (SCK) edge  
prior to the latch of the first data transfer. This first  
clock edge will freeze the data in the slave device  
DR register and output the MSBit on to the exter-  
nal MISO pin of the slave device.  
The SS pin signal must be always high on the  
master device.  
WCOL bit  
The WCOL bit in the SR register is set if a write  
collision occurs.  
The SS pin low state enables the slave device but  
the output of the MSBit onto the MISO pin does  
not take place until the first data transfer clock  
edge.  
No SPI interrupt is generated when the WCOL bit  
is set (the WCOL bit is a status flag only).  
Clearing the WCOL bit is done through a software  
sequence (see Figure 59).  
Figure 59. Clearing the WCOL bit (Write Collision Flag) Software Sequence  
Clearing sequence after SPIF = 1 (end of a data byte transfer)  
Read SR  
Read SR  
1st Step  
2nd Step  
OR  
THEN  
THEN  
SPIF =0  
WCOL=0  
SPIF =0  
WCOL=0 if no transfer has started  
WCOL=1 if a transfer has started  
before the 2nd step  
Read DR  
Write DR  
Clearing sequence before SPIF = 1 (during a data byte transfer)  
Read SR  
1st Step  
THEN  
Note: Writing to the DR register  
2nd Step  
Read DR  
instead of reading in it does not  
reset the WCOL bit.  
WCOL=0  
101/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
8.4.4.5 Master Mode Fault  
Hardware does not allow the user to set the SPE  
and MSTR bits while the MODF bit is set except in  
the MODF bit clearing sequence.  
Master mode fault occurs when the master device  
has its SS pin pulled low, then the MODF bit is set.  
In a slave device the MODF bit cannot be set, but  
in a multi master configuration the device can be in  
slave mode with this MODF bit set.  
Master mode fault affects the SPI peripheral in the  
following ways:  
– The MODF bit is set and an SPI interrupt is gen-  
erated if the SPIE bit is set.  
The MODF bit indicates that there might have  
been a multimaster conflict for system control and  
allows a proper exit from system operation to a re-  
set or default system state using an interrupt rou-  
tine.  
– The SPE bit is reset. This blocks all output from  
the device and disables the SPI peripheral.  
– The MSTR bit is reset, thus forcing the device  
into slave mode.  
8.4.4.6 Overrun Condition  
Clearing the MODF bit is done through a software  
sequence:  
An overrun condition occurs when the master de-  
vice has sent several data bytes and the slave de-  
vice has not cleared the SPIF bit issuing from the  
previous data byte transmitted.  
1. A read or write access to the SR register while  
the MODF bit is set.  
In this case, the receiver buffer contains the byte  
sent after the SPIF bit was last cleared. A read to  
the DR register returns this byte. All other bytes  
are lost.  
2. A write to the CR register.  
Notes: To avoid any multiple slave conflicts in the  
case of a system comprising several MCUs, the  
SS pin must be pulled high during the clearing se-  
quence of the MODF bit. The SPE and MSTR bits  
may be restored to their original state during or af-  
ter this clearing sequence.  
This condition is not detected by the SPI peripher-  
al.  
102/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
8.4.4.7 Single Master and Multimaster Configurations  
There are two types of SPI systems:  
– Single Master System  
For more security, the slave device may respond  
to the master with the received data byte. Then the  
master will receive the previous byte back from the  
slave device if all MISO and MOSI pins are con-  
nected and the slave has not written its DR regis-  
ter.  
– Multimaster System  
Single Master System  
Other transmission security methods can use  
ports for handshake lines or data bytes with com-  
mand fields.  
A typical single master system may be configured,  
using an MCU as the master and four MCUs as  
slaves (see Figure 60).  
Multimaster System  
The master device selects the individual slave de-  
vices by using four pins of a parallel port to control  
the four SS pins of the slave devices.  
A multimaster system may also be configured by  
the user. Transfer of master control could be im-  
plemented using a handshake method through the  
I/O ports or by an exchange of code messages  
through the serial peripheral interface system.  
The SS pins are pulled high during reset since the  
master device ports will be forced to be inputs at  
that time, thus disabling the slave devices.  
The multi-master system is principally handled by  
the MSTR bit in the CR register and the MODF bit  
in the SR register.  
Note: To prevent a bus conflict on the MISO line  
the master allows only one active slave device  
during a transmission.  
Figure 60. Single Master Configuration  
SS  
SS  
SS  
SS  
SCK  
SCK  
Slave  
SCK  
Slave  
SCK  
Slave  
Slave  
MCU  
MCU  
MCU  
MCU  
MOSI MISO  
MOSI MISO  
MOSI MISO  
MOSI MISO  
MOSI MISO  
SCK  
Master  
MCU  
5V  
SS  
103/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
8.4.5 Low Power Modes  
Mode  
Description  
No effect on SPI.  
SPI interrupt events cause the device to exit from WAIT mode.  
WAIT  
SPI registers are frozen.  
HALT  
In HALT mode, the SPI is inactive. SPI operation resumes when the MCU is woken up by an interrupt with  
“exit from HALT mode” capability.  
8.4.6 Interrupts  
Enable  
Control from  
Bit  
Exit  
Exit  
from  
Halt  
No  
No  
Event  
Flag  
Interrupt Event  
Wait  
Yes  
Yes  
SPI End of Transfer Event  
Master Mode Fault Event  
SPIF  
SPIE  
MODF  
Note: The SPI interrupt events are connected to  
the same interrupt vector (see Interrupts chapter).  
They generate an interrupt if the corresponding  
Enable Control Bit is set and the interrupt mask in  
the CC register is reset (RIM instruction).  
104/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
8.4.7 Register Description  
CONTROL REGISTER (CR)  
Read/Write  
Bit 3 = CPOL Clock polarity.  
This bit is set and cleared by software. This bit de-  
termines the steady state of the serial Clock. The  
CPOL bit affects both the master and slave  
modes.  
Reset Value: 0000 xxxx (0xh)  
7
0
SPIE SPE SPR2 MSTR CPOL CPHA SPR1 SPR0  
0: The steady state is a low value at the SCK pin.  
1: The steady state is a high value at the SCK pin.  
Bit 7 = SPIE Serial peripheral interrupt enable.  
This bit is set and cleared by software.  
0: Interrupt is inhibited  
1: An SPI interrupt is generated whenever SPIF=1  
or MODF=1 in the SR register  
Bit 2 = CPHA Clock phase.  
This bit is set and cleared by software.  
0: The first clock transition is the first data capture  
edge.  
1: The second clock transition is the first capture  
edge.  
Bit 6 = SPE Serial peripheral output enable.  
This bit is set and cleared by software. It is also  
cleared by hardware when, in master mode, SS=0  
(see Section 8.4.4.5 Master Mode Fault).  
0: I/O port connected to pins  
Bit 1:0 = SPR[1:0] Serial peripheral rate.  
These bits are set and cleared by software.Used  
with the SPR2 bit, they select one of six baud rates  
to be used as the serial clock when the device is a  
master.  
1: SPI alternate functions connected to pins  
The SPE bit is cleared by reset, so the SPI periph-  
eral is not initially connected to the external pins.  
These 2 bits have no effect in slave mode.  
Table 42. Serial Peripheral Baud Rate  
Bit 5 = SPR2 Divider Enable.  
Serial Clock  
SPR2 SPR1 SPR0  
This bit is set and cleared by software and it is  
cleared by reset. It is used with the SPR[1:0] bits to  
set the baud rate. Refer to Table 42.  
0: Divider by 2 enabled  
f
f
/4  
/8  
1
0
0
1
0
0
0
0
0
1
1
1
0
0
1
0
0
1
CPU  
CPU  
f
f
f
/16  
/32  
/64  
CPU  
CPU  
CPU  
1: Divider by 2 disabled  
Bit 4 = MSTR Master.  
f
/128  
CPU  
This bit is set and cleared by software. It is also  
cleared by hardware when, in master mode, SS=0  
(see Section 8.4.4.5 Master Mode Fault).  
0: Slave mode is selected  
1: Master mode is selected, the function of the  
SCK pin changes from an input to an output and  
the functions of the MISO and MOSI pins are re-  
versed.  
105/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
STATUS REGISTER (SR)  
Read Only  
DATA I/O REGISTER (DR)  
Read/Write  
Reset Value: 0000 0000 (00h)  
Reset Value: Undefined  
7
0
-
7
0
SPIF  
WCOL  
-
MODF  
-
-
-
D7  
D6  
D5  
D4  
D3  
D2  
D1  
D0  
Bit 7 = SPIF Serial Peripheral data transfer flag.  
This bit is set by hardware when a transfer has  
been completed. An interrupt is generated if  
SPIE = 1 in the CR register. It is cleared by a soft-  
ware sequence (an access to the SR register fol-  
lowed by a read or write to the DR register).  
0: Data transfer is in progress or has been ap-  
proved by a clearing sequence.  
The DR register is used to transmit and receive  
data on the serial bus. In the master device only a  
write to this register will initiate transmission/re-  
ception of another byte.  
Notes: During the last clock cycle the SPIF bit is  
set, a copy of the received data byte in the shift  
register is moved to a buffer. When the user reads  
the serial peripheral data I/O register, the buffer is  
actually being read.  
1: Data transfer between the device and an exter-  
nal device has been completed.  
Warning:  
Note: While the SPIF bit is set, all writes to the DR  
register are inhibited.  
A write to the DR register places data directly into  
the shift register for transmission.  
A read to the DR register returns the value located  
in the buffer and not the contents of the shift regis-  
ter (see Figure 56).  
Bit 6 = WCOL Write Collision status.  
This bit is set by hardware when a write to the DR  
register is done during a transmit sequence. It is  
cleared by a software sequence (see Figure 59).  
0: No write collision occurred  
1: A write collision has been detected  
Bit 5 = Unused.  
Bit 4 = MODF Mode Fault flag.  
This bit is set by hardware when the SS pin is  
pulled low in master mode (see Section 8.4.4.5  
Master Mode Fault). An SPI interrupt can be gen-  
erated if SPIE = 1 in the CR register. This bit is  
cleared by a software sequence (An access to the  
SR register while MODF = 1 followed by a write to  
the CR register).  
0: No master mode fault detected  
1: A fault in master mode has been detected  
Bits 3:0 = Unused.  
106/131  
ST72141K2-Auto  
SERIAL PERIPHERAL INTERFACE (Cont’d)  
Table 43. SPI Register Map and Reset Values  
Address  
(Hex.)  
Register  
Label  
7
6
5
4
3
2
1
0
SPIDR  
Reset Value  
MSB  
x
LSB  
x
0021h  
0022h  
0023h  
x
x
x
x
x
x
SPICR  
Reset Value  
SPIE  
0
SPE  
0
SPR2  
0
MSTR  
0
CPOL  
x
CPHA  
x
SPR1  
x
SPR0  
x
SPISR  
Reset Value  
SPIF  
0
WCOL  
0
MODF  
0
0
0
0
0
0
107/131  
ST72141K2-Auto  
8.5 8-BIT A/D CONVERTER (ADC)  
8.5.1 Introduction  
8.5.2 Main Features  
8-bit conversion  
The on-chip Analog to Digital Converter (ADC) pe-  
ripheral is an 8-bit, successive approximation con-  
verter with internal sample and hold circuitry. This  
peripheral has up to 8 multiplexed analog input  
channels (refer to device pinout description) that  
allow the peripheral to convert the analog voltage  
levels from up to 8 different sources.  
Up to 8 channels with multiplexed input  
Linear successive approximation  
Data register (DR) which contains the results  
Conversion complete status flag  
On/Off bit (to reduce consumption)  
The result of the conversion is stored in an 8-bit  
Data Register. The A/D converter is controlled  
through a Control/Status Register.  
The block diagram is shown in Figure 61.  
Figure 61. ADC Block Diagram  
-
ADON  
0
-
CH2 CH1 CH0  
COCO  
(Control Status Register) CSR  
AIN0  
AIN1  
AIN2  
AIN3  
AIN4  
AIN5  
AIN6  
AIN7  
SAMPLE  
&
HOLD  
ANALOG TO  
DIGITAL  
CONVERTER  
ANALOG  
MUX  
f
CPU  
AD6 AD5 AD4 AD3 AD2 AD1 AD0  
(Data Register) DR  
AD7  
108/131  
ST72141K2-Auto  
8-BIT A/D CONVERTER (ADC) (Cont’d)  
8.5.3 Functional Description  
The high level reference voltage V  
must be  
The accuracy of the conversion is described in the  
Electrical Characteristics Section.  
DDA  
connected externally to the V pin. The low level  
DD  
reference voltage V  
must be connected exter-  
SSA  
Procedure  
nally to the V pin. In some devices (refer to de-  
SS  
Refer to the CSR and DR register description sec-  
tion for the bit definitions.  
vice pinout description) high and low level refer-  
ence voltages are internally connected to the V  
DD  
and V pins.  
Each analog input pin must be configured as input,  
no pull-up, no interrupt. Refer to Section 6 I/O  
PORTS. Using these pins as analog inputs does  
not affect the ability of the port to be read as a logic  
input.  
SS  
Conversion accuracy may therefore be degraded  
by voltage drops and noise in the event of heavily  
loaded or badly decoupled power supply lines.  
Figure 62. Recommended Ext. Connections  
In the CSR register:  
– Select the CH2 to CH0 bits to assign the analog  
channel to convert. Refer to Table 44 Channel  
Selection.  
V
DD  
V
V
DDA  
SSA  
0.1µF  
– Set the ADON bit. Then the A/D converter is en-  
abled after a stabilization time (typically 30µs). It  
then performs a continuous conversion of the se-  
lected channel.  
ST7  
R
AIN  
V
Px.x/AINx  
AIN  
When a conversion is complete  
– The COCO bit is set by hardware.  
– No interrupt is generated.  
– The result is in the DR register.  
Characteristics  
A write to the CSR register aborts the current con-  
version, resets the COCO bit and starts a new  
conversion.  
The conversion is monotonic, meaning the result  
never decreases if the analog input does not and  
never increases if the analog input does not.  
If input voltage is greater than or equal to V  
(voltage reference high) then results = FFh (full  
scale) without overflow indication.  
DD  
8.5.4 Low Power Modes  
Note: The A/D converter may be disabled by re-  
setting the ADON bit. This feature allows reduced  
power consumption when no conversion is need-  
ed.  
If input voltage < V (voltage reference low) then  
SS  
the results = 00h.  
The conversion time is 64 CPU clock cycles in-  
cluding a sampling time of 31.5 CPU clock cycles.  
Mode  
Description  
No effect on A/D Converter  
A/D Converter disabled.  
WAIT  
R
is the maximum recommended impedance  
AIN  
for an analog input signal. If the impedance is too  
high, this will result in a loss of accuracy due to  
leakage and sampling not being completed in the  
allotted time.  
After wake-up from Halt mode, the A/D Con-  
verter requires a stabilization time before ac-  
curate conversions can be performed.  
HALT  
The A/D converter is linear and the digital result of  
the conversion is given by the formula:  
8.5.5 Interrupts  
255 x Input Voltage  
Digital result =  
None.  
Reference Voltage  
Where Reference Voltage is V - V  
.
SS  
DD  
109/131  
ST72141K2-Auto  
8-BIT A/D CONVERTER (ADC) (Cont’d)  
8.5.6 Register Description  
CONTROL/STATUS REGISTER (CSR)  
Read/Write  
These bits are set and cleared by software. They  
select the analog input to convert.  
Table 44. Channel Selection  
Reset Value: 0000 0000 (00h)  
Pin*  
AIN0  
AIN1  
AIN2  
AIN3  
AIN4  
AIN5  
AIN6  
AIN7  
CH2  
0
CH1  
0
CH0  
0
7
0
0
0
1
COCO  
-
ADON  
0
-
CH2  
CH1  
CH0  
0
1
0
0
1
1
Bit 7 = COCO Conversion Complete  
1
0
0
This bit is set by hardware. It is cleared by soft-  
ware reading the result in the DR register or writing  
to the CSR register.  
0: Conversion is not complete.  
1: Conversion can be read from the DR register.  
1
0
1
1
1
0
1
1
1
*IMPORTANT NOTE: The number of pins AND  
the channel selection vary according to the device  
(refer to the device pinout).  
Bit 6 = Reserved. Must always be cleared.  
Bit 5 = ADON A/D converter On  
DATA REGISTER (DR)  
Read Only  
This bit is set and cleared by software.  
0: A/D converter is switched off.  
1: A/D converter is switched on.  
Reset Value: 0000 0000 (00h)  
7
0
Note: A typical 30µs delay time is necessary for  
the ADC to stabilize when the ADON bit is set.  
AD7  
AD6  
AD5  
AD4  
AD3  
AD2  
AD1  
AD0  
Bit 4 = Reserved. Forced by hardware to 0.  
Bit 3 = Reserved. Must always be cleared.  
Bit 7:0 = AD[7:0] Analog Converted Value  
This register contains the converted analog value  
in the range 00h to FFh.  
Reading this register resets the COCO flag.  
Bits 2:0: CH[2:0] Channel Selection  
Table 45. ADC Register Map and Reset Values  
Address  
(Hex.)  
Register  
Label  
7
6
5
4
3
2
1
0
ADCDR  
Reset Value  
IS11  
0
IS10  
0
MCO  
0
IS21  
0
IS20  
0
CP1  
0
CP0  
0
SMS  
0
0070h  
0071h  
ADCCSR  
Standard  
Reset Value  
COCO  
0
ADON  
0
CH2  
0
CH1  
0
CH0  
0
0
0
0
110/131  
ST72141K2-Auto  
9 INSTRUCTION SET  
9.1 ST7 ADDRESSING MODES  
The ST7 Core features 17 different addressing  
modes which can be classified in 7 main groups:  
so, most of the addressing modes may be divided  
in two submodes called long and short:  
– Long addressing mode is more powerful be-  
cause it can use the full 64 Kbyte address space,  
however it uses more bytes and more CPU cy-  
cles.  
Addressing Mode  
Inherent  
Example  
nop  
Immediate  
Direct  
ld A,#$55  
ld A,$55  
ld A,($55,X)  
ld A,([$55],X)  
jrne loop  
– Short addressing mode is less powerful because  
it can generally only access page zero (0000h -  
00FFh range), but the instruction size is more  
compact, and faster. All memory to memory in-  
structions use short addressing modes only  
(CLR, CPL, NEG, BSET, BRES, BTJT, BTJF,  
INC, DEC, RLC, RRC, SLL, SRL, SRA, SWAP)  
Indexed  
Indirect  
Relative  
Bit operation  
bset byte,#5  
The ST7 Assembler optimizes the use of long and  
short addressing modes.  
The ST7 Instruction set is designed to minimize  
the number of bytes required per instruction: To do  
Table 46. ST7 Addressing Mode Overview  
Pointer  
Address  
(Hex.)  
Pointer  
Size  
(Hex.)  
Destination/  
Source  
Length  
(Bytes)  
Mode  
Syntax  
Inherent  
Immediate  
Short  
nop  
+ 0  
+ 1  
+ 1  
+ 2  
ld A,#$55  
ld A,$10  
Direct  
Direct  
00..FF  
Long  
ld A,$1000  
0000..FFFF  
+ 0 (with X register)  
+ 1 (with Y register)  
No Offset  
Direct  
Indexed ld A,(X)  
00..FF  
Short  
Long  
Short  
Long  
Short  
Long  
Relative  
Relative  
Bit  
Direct  
Indexed ld A,($10,X)  
Indexed ld A,($1000,X)  
ld A,[$10]  
00..1FE  
+ 1  
+ 2  
+ 2  
+ 2  
+ 2  
+ 2  
+ 1  
+ 2  
+ 1  
+ 2  
+ 2  
+ 3  
Direct  
0000..FFFF  
00..FF  
Indirect  
Indirect  
00..FF  
00..FF  
00..FF  
00..FF  
byte  
word  
byte  
word  
ld A,[$10.w]  
0000..FFFF  
00..1FE  
Indirect Indexed ld A,([$10],X)  
Indirect Indexed ld A,([$10.w],X) 0000..FFFF  
1)  
1)  
Direct  
jrne loop  
PC-128/PC+127  
PC-128/PC+127  
00..FF  
Indirect  
Direct  
jrne [$10]  
00..FF  
00..FF  
00..FF  
byte  
byte  
byte  
bset $10,#7  
bset [$10],#7  
Bit  
Indirect  
Direct  
00..FF  
Bit  
Relative btjt $10,#7,skip 00..FF  
Bit  
Indirect Relative btjt [$10],#7,skip 00..FF  
Notes:  
1. At the time the instruction is executed, the Program Counter (PC) points to the instruction following JRxx.  
111/131  
ST72141K2-Auto  
ST7 ADDRESSING MODES (Cont’d)  
9.1.1 Inherent  
9.1.3 Direct  
All Inherent instructions consist of a single byte.  
The opcode fully specifies all the required informa-  
tion for the CPU to process the operation.  
In Direct instructions, the operands are referenced  
by their memory address.  
The direct addressing mode consists of two sub-  
modes:  
Inherent Instruction  
Function  
No operation  
Direct (short)  
NOP  
The address is a byte, thus requires only one byte  
after the opcode, but only allows 00 - FF address-  
ing space.  
TRAP  
S/W Interrupt  
Wait For Interrupt (Low Power  
Mode)  
WFI  
Direct (long)  
Halt Oscillator (Lowest Power  
Mode)  
HALT  
The address is a word, thus allowing 64 Kbyte ad-  
dressing space, but requires 2 bytes after the op-  
code.  
RET  
Sub-routine Return  
Interrupt Sub-routine Return  
Set Interrupt Mask  
Reset Interrupt Mask  
Set Carry Flag  
IRET  
SIM  
9.1.4 Indexed (No Offset, Short, Long)  
RIM  
In this mode, the operand is referenced by its  
memory address, which is defined by the unsigned  
addition of an index register (X or Y) with an offset.  
SCF  
RCF  
Reset Carry Flag  
Reset Stack Pointer  
Load  
The indexed addressing mode consists of three  
submodes:  
RSP  
LD  
Indexed (No Offset)  
CLR  
Clear  
There is no offset, (no extra byte after the opcode),  
and allows 00 - FF addressing space.  
PUSH/POP  
INC/DEC  
TNZ  
Push/Pop to/from the stack  
Increment/Decrement  
Test Negative or Zero  
1 or 2 Complement  
Byte Multiplication  
Indexed (Short)  
The offset is a byte, thus requires only one byte af-  
ter the opcode and allows 00 - 1FE addressing  
space.  
CPL, NEG  
MUL  
Indexed (long)  
SLL, SRL, SRA, RLC,  
RRC  
Shift and Rotate Operations  
Swap Nibbles  
The offset is a word, thus allowing 64 Kbyte ad-  
dressing space and requires 2 bytes after the op-  
code.  
SWAP  
9.1.2 Immediate  
Immediate instructions have two bytes, the first  
byte contains the opcode, the second byte con-  
tains the operand value.  
9.1.5 Indirect (Short, Long)  
The required data byte to do the operation is found  
by its memory address, located in memory (point-  
er).  
Immediate Instruction  
Function  
The pointer address follows the opcode. The indi-  
rect addressing mode consists of two submodes:  
LD  
Load  
CP  
Compare  
Indirect (short)  
BCP  
Bit Compare  
The pointer address is a byte, the pointer size is a  
byte, thus allowing 00 - FF addressing space, and  
requires 1 byte after the opcode.  
AND, OR, XOR  
ADC, ADD, SUB, SBC  
Logical Operations  
Arithmetic Operations  
Indirect (long)  
The pointer address is a byte, the pointer size is a  
word, thus allowing 64 Kbyte addressing space,  
and requires 1 byte after the opcode.  
112/131  
ST72141K2-Auto  
ST7 ADDRESSING MODES (Cont’d)  
9.1.6 Indirect Indexed (Short, Long)  
9.1.7 Relative Mode (Direct, Indirect)  
This is a combination of indirect and short indexed  
addressing modes. The operand is referenced by  
its memory address, which is defined by the un-  
signed addition of an index register value (X or Y)  
with a pointer value located in memory. The point-  
er address follows the opcode.  
This addressing mode is used to modify the PC  
register value by adding an 8-bit signed offset to it.  
Available Relative Direct/  
Function  
Indirect Instructions  
JRxx  
Conditional Jump  
Call Relative  
The indirect indexed addressing mode consists of  
two submodes:  
CALLR  
The relative addressing mode consists of two sub-  
modes:  
Indirect Indexed (Short)  
The pointer address is a byte, the pointer size is a  
byte, thus allowing 00 - 1FE addressing space,  
and requires 1 byte after the opcode.  
Relative (Direct)  
The offset follows the opcode.  
Relative (Indirect)  
Indirect Indexed (Long)  
The pointer address is a byte, the pointer size is a  
word, thus allowing 64 Kbyte addressing space,  
and requires 1 byte after the opcode.  
The offset is defined in memory, of which the ad-  
dress follows the opcode.  
Table 47. Instructions Supporting Direct,  
Indexed, Indirect and Indirect Indexed  
Addressing Modes  
Long and Short  
Function  
Instructions  
LD  
Load  
CP  
Compare  
AND, OR, XOR  
Logical Operations  
Arithmetic Addition/subtrac-  
tion operations  
ADC, ADD, SUB, SBC  
BCP  
Bit Compare  
Short Instructions Only  
CLR  
Function  
Clear  
INC, DEC  
Increment/Decrement  
Test Negative or Zero  
1 or 2 Complement  
Bit Operations  
TNZ  
CPL, NEG  
BSET, BRES  
Bit Test and Jump Opera-  
tions  
BTJT, BTJF  
SLL, SRL, SRA, RLC,  
RRC  
Shift and Rotate Operations  
SWAP  
Swap Nibbles  
CALL, JP  
Call or Jump subroutine  
113/131  
ST72141K2-Auto  
9.2 INSTRUCTION GROUPS  
The ST7 family devices use an Instruction Set  
consisting of 63 instructions. The instructions may  
be subdivided into 13 main groups as illustrated in  
the following table:  
Load and Transfer  
LD  
CLR  
POP  
DEC  
TNZ  
OR  
Stack operation  
PUSH  
INC  
RSP  
BCP  
Increment/Decrement  
Compare and Tests  
Logical operations  
CP  
AND  
BSET  
BTJT  
ADC  
SLL  
XOR  
CPL  
NEG  
Bit Operation  
BRES  
BTJF  
ADD  
SRL  
JRT  
Conditional Bit Test and Branch  
Arithmetic operations  
Shift and Rotates  
SUB  
SRA  
JRF  
SBC  
RLC  
JP  
MUL  
RRC  
CALL  
SWAP  
CALLR  
SLA  
Unconditional Jump or Call  
Conditional Branch  
JRA  
JRxx  
TRAP  
SIM  
NOP  
RET  
Interruption management  
Condition Code Flag modification  
WFI  
RIM  
HALT  
SCF  
IRET  
RCF  
Using a prebyte  
The instructions are described with one to four  
bytes.  
These prebytes enable instruction in Y as well as  
indirect addressing modes to be implemented.  
They precede the opcode of the instruction in X or  
the instruction using direct addressing mode. The  
prebytes are:  
In order to extend the number of available op-  
codes for an 8-bit CPU (256 opcodes), three differ-  
ent prebyte opcodes are defined. These prebytes  
modify the meaning of the instruction they pre-  
cede.  
PDY 90 Replace an X based instruction using  
immediate, direct, indexed, or inherent  
addressing mode by a Y one.  
The whole instruction becomes:  
PC-2 End of previous instruction  
PC-1 Prebyte  
PIX 92 Replace an instruction using direct, di-  
rect bit, or direct relative addressing  
mode to an instruction using the corre-  
sponding indirect addressing mode.  
It also changes an instruction using X  
indexed addressing mode to an instruc-  
tion using indirect X indexed addressing  
mode.  
PC  
Opcode  
PC+1 Additional word (0 to 2) according to the  
number of bytes required to compute the  
effective address  
PIY 91 Replace an instruction using X indirect  
indexed addressing mode by a Y one.  
114/131  
ST72141K2-Auto  
INSTRUCTION GROUPS (Cont’d)  
Mnemo  
ADC  
ADD  
AND  
BCP  
Description  
Add with Carry  
Function/Example  
A = A + M + C  
A = A + M  
Dst  
Src  
H
H
H
I
N
N
N
N
N
Z
Z
Z
Z
Z
C
C
C
A
M
M
M
M
Addition  
A
Logical And  
A = A . M  
A
Bit compare A, Memory  
Bit Reset  
tst (A . M)  
A
BRES  
BSET  
BTJF  
BTJT  
CALL  
CALLR  
CLR  
bres Byte, #3  
bset Byte, #3  
btjf Byte, #3, Jmp1  
btjt Byte, #3, Jmp1  
M
M
M
M
Bit Set  
Jump if bit is false (0)  
Jump if bit is true (1)  
Call subroutine  
Call subroutine relative  
Clear  
C
C
reg, M  
reg  
0
N
N
N
1
Z
Z
Z
CP  
Arithmetic Compare  
One Complement  
Decrement  
tst(Reg - M)  
A = FFH-A  
dec Y  
M
C
1
CPL  
reg, M  
reg, M  
DEC  
HALT  
IRET  
INC  
Halt  
0
I
Interrupt routine return  
Increment  
Pop CC, A, X, PC  
inc X  
H
N
N
Z
Z
C
reg, M  
JP  
Absolute Jump  
Jump relative always  
Jump relative  
jp [TBL.w]  
JRA  
JRT  
JRF  
Never jump  
jrf *  
JRIH  
JRIL  
Jump if ext. interrupt = 1  
Jump if ext. interrupt = 0  
Jump if H = 1  
JRH  
H = 1 ?  
JRNH  
JRM  
Jump if H = 0  
H = 0 ?  
Jump if I = 1  
I = 1 ?  
JRNM  
JRMI  
JRPL  
JREQ  
JRNE  
JRC  
Jump if I = 0  
I = 0 ?  
Jump if N = 1 (minus)  
Jump if N = 0 (plus)  
Jump if Z = 1 (equal)  
Jump if Z = 0 (not equal)  
Jump if C = 1  
N = 1 ?  
N = 0 ?  
Z = 1 ?  
Z = 0 ?  
C = 1 ?  
JRNC  
JRULT  
Jump if C = 0  
C = 0 ?  
Jump if C = 1  
Unsigned <  
Jmp if unsigned >=  
Unsigned >  
JRUGE Jump if C = 0  
JRUGT Jump if (C + Z = 0)  
115/131  
ST72141K2-Auto  
INSTRUCTION GROUPS (Cont’d)  
Mnemo  
JRULE  
LD  
Description  
Jump if (C + Z = 1)  
Load  
Function/Example  
Unsigned <=  
dst <= src  
Dst  
Src  
H
I
N
N
N
N
N
Z
Z
Z
Z
Z
C
reg, M  
A, X, Y  
reg, M  
M, reg  
X, Y, A  
MUL  
NEG  
NOP  
OR  
Multiply  
X,A = X * A  
0
0
Negate (2's compl)  
No Operation  
OR operation  
Pop from the Stack  
neg $10  
C
A = A + M  
pop reg  
pop CC  
push Y  
C = 0  
A
M
POP  
reg  
CC  
M
M
M
H
I
C
0
PUSH  
RCF  
RET  
RIM  
Push onto the Stack  
Reset carry flag  
Subroutine Return  
Enable Interrupts  
Rotate left true C  
Rotate right true C  
Reset Stack Pointer  
Subtract with Carry  
Set carry flag  
reg, CC  
I = 0  
0
RLC  
RRC  
RSP  
SBC  
SCF  
SIM  
C <= Dst <= C  
C => Dst => C  
S = Max allowed  
A = A - M - C  
C = 1  
reg, M  
reg, M  
N
N
Z
Z
C
C
A
M
N
Z
C
1
Disable Interrupts  
Shift left Arithmetic  
Shift left Logic  
I = 1  
1
SLA  
C <= Dst <= 0  
C <= Dst <= 0  
0 => Dst => C  
Dst7 => Dst => C  
A = A - M  
reg, M  
reg, M  
reg, M  
reg, M  
A
N
N
0
Z
Z
Z
Z
Z
Z
Z
C
C
C
C
C
SLL  
SRL  
SRA  
SUB  
SWAP  
TNZ  
TRAP  
WFI  
Shift right Logic  
Shift right Arithmetic  
Subtraction  
N
N
N
N
M
M
SWAP nibbles  
Dst[7..4] <=> Dst[3..0] reg, M  
tnz lbl1  
Test for Neg & Zero  
S/W trap  
S/W interrupt  
1
0
Wait for Interrupt  
Exclusive OR  
XOR  
A = A XOR M  
A
N
Z
116/131  
ST72141K2-Auto  
10 ELECTRICAL CHARACTERISTICS  
10.1 ABSOLUTE MAXIMUM RATINGS  
This product contains devices for protecting the in-  
puts against damage due to high static voltages,  
however it is advisable to take normal precautions  
to avoid applying any voltage higher than the  
specified maximum rated voltages.  
Power Considerations. The average chip-junc-  
tion temperature, T , in Celsius can be obtained  
J
from:  
Where: T =  
T + P x R  
A D thJA  
J
T =  
Ambient temperature  
= Package thermal resistance  
(junction-to ambient)  
A
R
For proper operation it is recommended that V  
thJA  
I
and V be higher than V and lower than V  
.
O
SS  
DD  
P =  
P
+ P  
Reliability is enhanced if unused inputs are con-  
D
INT  
PORT  
INT PORT  
P
P
= I x V (chip internal power)  
nected to an appropriate logic voltage level (V  
DD DD  
DD  
or V ).  
=Port power dissipation  
determined by the user)  
SS  
Symbol  
- V  
Ratings  
Value  
Unit  
V
V
Supply voltage  
6.5  
DD  
SS  
Input voltage on true open drain pin  
Input voltage on any other pin  
Output voltage  
V
- 0.3 to 6.5  
V
SS  
V
IN  
V
V
- 0.3 to V + 0.3  
DD  
SS  
SS  
V
- 0.3 to V + 0.3  
V
V
OUT  
DD  
ESD  
ESD susceptibility  
2000  
80  
I
Total current into V  
(source)  
DD_i  
VDD_i  
mA  
I
Total current out of V  
(sink)  
SS_i  
80  
VSS_i  
Note:  
Stresses above those listed as “absolute maximum ratings” may cause permanent damage to the device. This is a stress  
rating only and functional operation of the device at these conditions is not implied. Exposure to maximum rating condi-  
tions for extended periods may affect device reliability.  
General Warning:  
Direct connection to V or V of the RESET and I/O pins could damage the device in case of unintentional internal  
DD  
SS  
reset generation or program counter corruption (due to unwanted change of the I/O configuration). To guarantee safe  
conditions, this connection has to be done through a 10ktypical pull-up or pull-down resistor.  
Thermal Characteristics  
Symbol  
Ratings  
Package thermal resistance  
Max. junction temperature  
Storage temperature range  
Power dissipation  
Value  
75  
Unit  
°C/W  
°C  
R
SO34  
thJA  
T
150  
Jmax  
T
-65 to +150  
500  
°C  
STG  
P
mW  
D
117/131  
ST72141K2-Auto  
10.2 RECOMMENDED OPERATING CONDITIONS  
GENERAL  
1)  
Symbol  
Parameter  
Supply voltage  
Conditions  
Min  
Typ  
Max  
Unit  
V
4.0  
5.5  
V
DD  
Resonator oscillator frequency  
External clock source  
2)  
f
8 or 16  
MHz  
°C  
OSC  
T
Ambient temperature range  
-40  
85  
A
10.3 DC ELECTRICAL CHARACTERISTICS  
o
Recommended operating conditions with T =-40 to +125 C, V -V =5V unless otherwise specified.  
A
DD SS  
1)  
Symbol  
Parameter  
Conditions  
Min  
Typ  
Max  
Unit  
5
7
8
12  
f
f
= 8 MHz, f  
= 4 MHz  
= 8 MHz  
3)  
OSC  
OSC  
CPU  
CPU  
Supply current in RUN mode  
= 16 MHz, f  
0.7  
1
1.1  
1.7  
f
f
= 8 MHz, f  
= 250 kHz  
= 500 kHz  
3)  
OSC  
OSC  
CPU  
CPU  
Supply current in SLOW mode  
= 16 MHz, f  
mA  
I
2
3.3  
3
5
f
f
= 8MHz, f  
= 4 MHz  
= 8 MHz  
4)  
DD  
OSC  
OSC  
CPU  
Supply current in WAIT mode  
= 16MHz, f  
CPU  
0.65  
0.8  
1
1.4  
f
f
= 8 MHz, f  
= 250 kHz  
= 500 kHz  
4)  
OSC  
OSC  
CPU  
CPU  
Supply current in SLOW WAIT mode  
= 16 MHz, f  
5)  
Supply current in HALT mode  
I
= 0mA (current on I/Os)  
200  
µA  
V
LOAD  
6)  
V
Data retention mode  
HALT mode  
2
RM  
10.4 GENERAL TIMING CHARACTERISTICS  
Symbol  
Parameter  
Instruction time  
Interrupt reaction time  
Conditions  
Min  
2
Typ  
Max  
Unit  
t
12  
22  
t
t
INST  
CPU  
CPU  
7)  
t
t
= t + 10  
INST  
10  
IRT  
IRT  
Notes:  
1. Unless otherwise specified, typical data is based on T =25°C and V -V =5V. This data is provided only as design  
A
DD SS  
guidelines and is not tested.  
2. Fixed frequencies required to obtain 4MHz for the motor control peripheral.  
3. CPU running with memory access, all I/O pins in input mode with a static value at V or V , all peripherals switched  
DD  
SS  
off; clock input (OSC2) driven by external square wave.  
4. All I/O pins in input mode with a static value at V or V , all peripherals switched off; clock input (OSC2) driven by  
DD  
SS  
external square wave.  
5. All I/O pins in input mode with a static value at V or V  
.
SS  
DD  
6. Data based on characterization results, not tested in production.  
7. tINST is the number of tCPU to finish the current instruction execution.  
118/131  
ST72141K2-Auto  
10.5 I/O PORT CHARACTERISTICS  
Recommended operating conditions  
o
with T =-40 to +125 C and 4.5V<V -V <5.5V unless otherwise specified.  
A
DD SS  
I/O PORT PINS  
Symbol  
1)  
Parameter  
Conditions  
Min  
0.7xV  
Typ  
Max  
Unit  
V
2)  
V
Input low level voltage  
0.3xV  
IL  
DD  
2)  
V
Input high level voltage  
IH  
DD  
3)  
V
Schmitt trigger voltage hysteresis  
400  
mV  
HYS  
I=-5mA  
I=-2mA  
I=-20mA  
I=-8mA  
I=-5mA  
I=-2mA  
1.3  
0.5  
1.3  
0.5  
Output low level voltage  
for standard I/O port pins  
V
OL  
Output low level voltage  
for high sink I/O port pins  
V
V
V
-2.0  
-0.8  
DD  
DD  
V
Output high level voltage  
OH  
40  
120  
80  
240  
V
> V  
20  
50  
IN  
IN  
IH  
IL  
R
Pull-up equivalent resistor  
Input leakage current  
kΩ  
PU  
V
< V  
I
V
<V <V  
SS PIN DD  
1
L
µA  
2)  
I
Static current consumption  
Floating input mode  
200  
5
SV  
5)  
Positive : V  
>V  
DD  
EXT  
I
Single pin injected current  
PINJ  
6)  
Negative : V  
Positive: V  
<V  
-5  
EXT  
SS  
mA  
7)  
>V  
20  
20  
Total injected current  
EXT  
DD  
I
INJ  
(sum of all I/O and control pins)  
Output high to low level fall time  
Output low to high rise time  
Negative: V  
<V  
SS  
EXT  
4)  
4)  
4)  
t
14.8  
14.4  
1
25  
25  
45.6  
45.9  
OHL  
OLH  
C =50pF  
ns  
l
4)  
t
8)  
t
External interrupt pulse time  
t
CPU  
ITEXT  
Notes:  
1. Unless otherwise specified, typical data is based on T =25°C and V -V =5V. This data is provided only as design  
A
DD SS  
guidelines and is not tested.  
2. Data based on design simulations and/or technology characteristics, not tested in production.  
3. Hysteresis voltage between Schmitt trigger switching levels. Based on characterization results, not tested.  
4. Data based on characterization results, not tested in production.  
5. Positive injection (I  
)
INJ+  
The I  
is performed through protection diodes insulated from the substrate of the die.  
INJ+  
The true open-drain pins do not accept positive injection. In this case the maximum voltage rating must be respected.  
6. ADC accuracy reduced by negative injection (I  
)
INJ-  
The I  
is performed through protection diodes NOT INSULATED from the substrate of the die. The drawback is a small  
INJ-  
leakage (a few µA) induced inside the die when a negative injection is performed. This leakage is tolerated by the digital  
structure, but it acts on the analog line depending on the impedance versus a leakage current of a few µA (if the MCU  
has an AD converter). The effect depends on the pin which is submitted to the injection. Of course, external digital signals  
applied to the component must have a maximum impedance close to 50k.  
Location of the negative current injection:  
- Pins with analog input capability are the most sensitive. I  
maximum is 0.8mA (assuming that the impedance of the  
INJ-  
analog voltage is lower than 25k).  
- Pure digital pins can tolerate 1.6mA. In addition, the best choice is to inject the current as far as possible from the analog  
input pins.  
7. When several inputs are submitted to a current injection, the maximum I is the sum of the positive (or negative) cur-  
INJ  
rents (instantaneous values). These results are based on characterization with I maximum current injection on four I/  
INJ  
O port pins of the device.  
8. To generate an external interrupt, a minimum pulse width has to be applied on an I/O port pin configured as an external  
interrupt source.  
119/131  
ST72141K2-Auto  
10.6 SUPPLY, RESET AND CLOCK CHARACTERISTICS  
10.6.1 Supply Manager  
o
Recommended operating conditions with T = -40 to +125 C and voltages referred to V  
.
A
SS  
LOW VOLTAGE DETECTOR (LVD)  
1)  
Symbol  
Parameter  
Conditions  
Min  
3.5  
0.2  
Typ  
4.05  
3.75  
250  
Max  
4.30  
4.0  
Unit  
V
Reset release threshold  
V
rise  
fall  
LVDr  
DD  
V
V
V
V
Reset generation threshold  
V
DD  
LVDf  
2)  
V
V
Hysteresis  
V
- V  
LVDf  
mV  
V/ms  
µA  
LVDhyst  
tPOR  
LVD  
LVDr  
3)  
rise time rate  
50  
DD  
4)  
I
LVD Supply Current  
HALT mode  
100  
200  
DD  
10.6.2 RESET Sequence Manager  
o
Recommended operating conditions with T = -40 to +125 C and 4.5V < V - V < 5.5V.  
A
DD  
SS  
RESET SEQUENCE MANAGER (RSM)  
5)  
Symbol  
Parameter  
Conditions  
Min  
Typ  
Max  
Unit  
V
V
> V  
5
20  
10  
80  
20  
180  
IN  
IN  
IH  
R
Reset weak pull-up resistance  
kΩ  
ON  
> V  
SS  
Reset delay for external and  
watchdog reset sources  
6
30  
1/f  
SFOSC  
t
t
DELAYmin  
µs  
External RESET pin Pulse time  
20  
µs  
PULSE  
10.6.3 Clock System  
o
Recommended operating conditions with T = -40 to +125 C and voltages referred to V  
.
A
SS  
EXTERNAL CLOCK SOURCE  
Symbol  
Parameter  
Conditions  
Min  
Typ  
Max  
Unit  
V
OSC2 input pin high level voltage  
OSC2 input pin low level voltage  
0.7xV  
V
Square wave signal  
with ~50% Duty Cycle  
OSC2h  
OSC2l  
DD  
DD  
V
V
V
0.3xV  
DD  
SS  
CRYSTAL AND CERAMIC RESONATOR OSCILLATORS  
5)  
Symbol  
Parameter  
Conditions  
Min  
Typ  
Max  
Unit  
MHz  
pF  
6)  
f
Oscillator Frequency  
8
16  
OSC  
7)  
8)  
6)  
C
Load Capacitor  
R
=100 Ω  
Smax  
15  
18  
21  
Li  
4)  
I
t
Supply Current  
700  
1100  
µA  
DD  
Oscillator start-up time  
Depends on resonator quality. A typical value is 10ms.  
START  
Notes:  
1. LVD typical data is based on T =25°C. This data is provided only as design guidelines and are not tested.  
A
2. The V  
hysteresis is constant.  
LVDhyst  
3. The V rise time rate condition is needed to ensure a correct device power-on reset. Not tested in production.  
DD  
4. Data based on characterization results, not tested in production.  
5. Unless otherwise specified, typical data is based on T =25°C and V -V =5V. This data is provided only as design  
A
DD SS  
guidelines and is not tested.  
6. This data is based on typical a R  
a high quality resonator.  
value. The oscillator selection can be optimized in terms of supply current with  
Smax  
7. R  
is the equivalent serial resistor of the crystal or ceramic resonator.  
Smax  
8. Data based on design simulations and/or technology characteristics, not tested in production.  
120/131  
ST72141K2-Auto  
10.7 MEMORY AND PERIPHERAL CHARACTERISTICS  
EPROM  
Symbol  
Parameter  
Conditions  
Min  
Typ  
Max  
Unit  
W-sec/  
cm  
W
UV lamp  
Lamp wavelength 2537Å  
15  
2
ERASE  
UV lamp placed 1 inch from  
the device window without  
any interposed filters  
t
Erase Time  
15  
20  
min  
ERASE  
WATCHDOG  
Symbol  
Parameter  
Conditions  
Min  
12288  
1.54  
Typ  
Max  
786432  
98.3  
Unit  
t
CPU  
t
Watchdog time-out duration  
Watchdog RESET pulse width  
w(WDG)  
f
=8MHz  
ms  
CPU  
t
500  
ns  
WDGRST  
o
Recommended operating conditions with T =-40 to +125 C and V -V =5V unless otherwise specified.  
A
DD SS  
MOTOR CONTROL  
Symbol  
1)  
Parameter  
Conditions  
Min  
35  
Typ  
<10  
Max  
100  
130  
1
Unit  
mV  
mV  
µs  
V
V
Comparator offset error  
OFFSET  
MTChyst  
PROPAG  
2)  
MCIA/B/C comparator hysteresis  
Comparator propagation delay  
80  
t
V  
V
REF  
REF  
Reference voltage tolerance  
5
%
R1  
R2  
30  
70  
kΩ  
V
resistance bridge  
CREF  
R2  
R1+R2  
α=  
0.7  
∆α/α  
α tolerance  
5
%
Note:  
1) Unless otherwise specified, typical data is based on T = 25° C and V -V = 5 V. This data is provided only as de-  
A
DD SS  
sign guidelines and are not tested.  
2) The V hysteresis is constant.  
MTChyst  
Figure 63. Motor Control Comparator Characteristics  
V
V
MTChyst  
2
V
V
+
-
V
V
REF  
OFFSET  
MTChyst  
2
REF  
OFFSET  
COMPARATOR  
IDEAL  
V
IN  
REAL  
t
t
PROPAG  
PROPAG  
t
121/131  
ST72141K2-Auto  
MEMORY AND PERIPHERAL CHARACTERISTICS (Cont’d)  
SPI Serial Peripheral Interface  
1)  
Value  
Min  
Ref.  
Symbol  
Parameter  
SPI frequency  
Condition  
Unit  
Max  
Master  
Slave  
1/128  
dc  
1/4  
1/2  
f
t
f
t
SPI  
SPI  
CPU  
Master  
Slave  
4
2
1
SPI clock period  
CPU  
2
3
t
Enable lead time  
Enable lag time  
Slave  
Slave  
120  
120  
ns  
ns  
Lead  
t
Lag  
Master  
Slave  
100  
90  
4
5
t
Clock (SCK) high time  
Clock (SCK) low time  
Data set-up time  
ns  
ns  
ns  
ns  
ns  
ns  
SPI_H  
Master  
Slave  
100  
90  
t
SPI_L  
Master  
Slave  
100  
100  
6
t
SU  
Master  
Slave  
100  
100  
7
t
Data hold time (inputs)  
H
Access time (time to data active  
from high impedance state)  
8
t
0
120  
240  
A
Slave  
Disable time (hold time to high im-  
pedance state)  
9
t
Dis  
Master (before capture edge)  
Slave (after enable edge)  
0.25  
t
t
CPU  
ns  
10  
11  
12  
13  
t
Data valid  
V
120  
Master (before capture edge)  
Slave (after enable edge)  
0.25  
0
CPU  
ns  
t
Data hold time (outputs)  
Rise time  
Hold  
Outputs: SCK,MOSI,MISO  
(20% V to 70% V , C = 200pF) Inputs: SCK,MOSI,MISO,SS  
100  
100  
ns  
µs  
t
Rise  
DD  
DD  
L
Fall time  
Outputs: SCK,MOSI,MISO  
(70% V to 20% V , C = 200pF) Inputs: SCK,MOSI,MISO,SS  
100  
100  
ns  
µs  
t
Fall  
DD  
DD  
L
Figure 64. SPI Master Timing Diagram CPHA = 0, CPOL = 0 2)  
SS  
(INPUT)  
1
13  
12  
SCK  
(OUTPUT)  
5
4
MISO  
(INPUT)  
D7-IN  
7
D6-IN  
D0-IN  
6
MOSI  
(OUTPUT)  
D7-OUT  
11  
D6-OUT  
D0-OUT  
10  
VR000109  
Notes:  
1. Data based on characterization results, not tested in production  
2. Measurement points are V , V , V and V in the SPI timing diagram  
OL  
OH  
IL  
IH  
122/131  
ST72141K2-Auto  
MEMORY AND PERIPHERAL CHARACTERISTICS (Cont’d)  
Figure 65. SPI Master Timing Diagram CPHA = 0, CPOL = 1 1)  
SS  
(INPUT)  
1
13  
12  
12  
13  
SCK  
(OUTPUT)  
5
4
MISO  
(INPUT)  
D7-IN  
7
D6-IN  
D0-IN  
6
MOSI  
(OUTPUT)  
D7-OUT  
11  
D6-OUT  
D0-OUT  
10  
VR000110  
VR000107  
VR000108  
Figure 66. SPI Master Timing Diagram CPHA = 1, CPOL = 0 1)  
SS  
(INPUT)  
1
13  
SCK  
(OUTPUT)  
4
5
MISO  
(INPUT)  
D7-OUT  
D6-OUT  
D0-OUT  
6
7
MOSI  
(OUTPUT)  
D7-IN  
11  
D6-IN  
D0-IN  
10  
Figure 67. SPI Master Timing Diagram CPHA = 1, CPOL = 1 1)  
SS  
(INPUT)  
1
12  
SCK  
(OUTPUT)  
5
4
MISO  
(INPUT)  
D7-IN  
7
D6-IN  
D0-IN  
6
MOSI  
(OUTPUT)  
D7-OUT  
11  
D6-OUT  
D0-OUT  
10  
Note:  
1) Measurement points are V , V , V and V in the SPI timing diagram  
OL  
OH  
IL  
IH  
123/131  
ST72141K2-Auto  
MEMORY AND PERIPHERAL CHARACTERISTICS (Cont’d)  
Measurement points are V , V , V and V in the SPI Timing Diagram.  
OL  
OH  
IL  
IH  
Figure 68. SPI Slave Timing Diagram CPHA = 0, CPOL = 0 1)  
SS  
(INPUT)  
2
1
12  
3
13  
11  
SCK  
(INPUT)  
4
5
HIGH-Z  
8
MISO  
D7-OUT  
D6-OUT  
D6-IN  
D0-OUT  
D0-IN  
(OUTPUT)  
10  
9
MOSI  
(INPUT)  
D7-IN  
7
6
VR000113  
Figure 69. SPI Slave Timing Diagram CPHA = 0, CPOL = 1 1)  
SS  
(INPUT)  
2
1
13  
12  
11  
3
SCK  
(INPUT)  
4
5
MISO  
HIGH-Z  
8
D7-OUT  
D6-OUT  
D6-IN  
D0-OUT  
D0-IN  
(OUTPUT)  
10  
9
MOSI  
(INPUT)  
D7-IN  
7
6
VR000114  
Figure 70. SPI Slave Timing Diagram CPHA = 1, CPOL = 0 1)  
SS  
(INPUT)  
2
1
13  
12  
3
SCK  
(INPUT)  
4
5
HIGH-Z  
8
MISO  
D7-OUT  
D6-OUT  
D6-IN  
D0-OUT  
D0-IN  
(OUTPUT)  
11  
9
10  
MOSI  
(INPUT)  
D7-IN  
7
6
VR000111  
Figure 71. SPI Slave Timing Diagram CPHA = 1, CPOL = 1 1)  
SS  
(INPUT)  
2
1
12  
13  
3
SCK  
(INPUT)  
5
4
HIGH-Z  
8
MISO  
D7-OUT  
D6-OUT  
D6-IN  
D0-OUT  
(OUTPUT)  
11  
10  
9
MOSI  
(INPUT)  
D7-IN  
D0-IN  
7
6
VR000112  
Notes:  
1. Measurement points are V , V , V and V in the SPI timing diagram  
OL  
OH  
IL  
IH  
124/131  
ST72141K2-Auto  
MEMORY AND PERIPHERAL CHARACTERISTICS (Cont’d)  
ADC Analog to Digital Converter (8-bit)  
1)  
Symbol  
|TUE|  
OE  
Parameter  
Conditions  
Min  
Typ  
Max  
Unit  
3)  
Total unadjusted error  
2
1
2
1
2
3)  
Offset error  
-1  
-2  
2)  
T =25°C,V =V  
=5V,  
3)  
A
DD  
DDA  
GE  
Gain Error  
LSB  
f
=8MHz  
CPU  
3)  
|DLE|  
|ILE|  
Differential linearity error  
3)  
Integral linearity error  
V
Conversion range voltage  
V
V
DDA  
V
AIN  
ADC  
STAB  
SSA  
I
t
A/D conversion supply current  
Stabilization time after ADC enable  
1
8
mA  
µs  
30  
f
V
=f  
=V  
=4MHz  
=5V  
µs  
1/f  
ADC CPU  
t
Sample capacitor loading time  
Hold conversion time  
LOAD  
CONV  
32  
DD  
DDA  
ADC  
8
32  
µs  
1/f  
t
ADC  
4)  
R
R
C
External input resistor  
Internal input resistor  
Sample capacitor  
20  
kΩ  
AIN  
18  
22  
kΩ  
ADC  
pF  
SAMPLE  
Notes:  
1. Unless otherwise specified, typical data is based on T =25°C and V -V =5V. This data is provided only for design  
A
DD SS  
guidelines and is not tested.  
2. Tested in production at T =25°C, characterized over all temperature range.  
A
3. ADC Accuracy vs. Negative Injection Current:  
For I =0.8mA, the typical leakage induced inside the die is 1.6µA and the effect on the ADC accuracy is a loss of 1 LSB  
INJ-  
by 10kincrease of the external analog source impedance.  
These measurement results and recommendations have been done under worst conditions for injection:  
- negative injection  
- injection to an Input with analog capability, adjacent to the enabled Analog Input  
- at 5V V supply, and worst case temperature.  
DD  
4. Data based on characterization results, not tested in production.  
125/131  
ST72141K2-Auto  
MEMORY AND PERIPHERAL CHARACTERISTICS (Cont’d)  
Figure 72. Typical A/D converter application  
V
Sampling  
Switch  
DD  
V = 0.6V  
R
T
AIN  
V
AIN  
R
SS  
Px.x/AINx  
SS  
2kΩ  
C
pin  
C
6 pF  
hold  
5pF  
C
= input capacitance  
= threshold voltage  
= sampling switch  
pin  
V
T
leakage  
1µA  
V = 0.6V  
T
SS  
C
V
= sample/hold  
capacitance  
SS  
hold  
leakage  
= leakage current  
at the pin due  
to various junctions  
Figure 73. ADC Error Classification  
Digital Result ADCDR  
GE  
(1) Example of an actual transfer curve  
(2) The ideal transfer curve  
(3) End point correlation line  
255  
V
V  
254  
253  
DDA  
SSA  
1LSB  
= ----------------------------------------  
ideal  
256  
(2)  
TUE=Total Unadjusted Error: maximum deviation  
between the actual and the ideal transfer curves.  
(3)  
TUE  
7
6
5
4
3
2
1
OE=Offset Error: deviation between the first actual  
transition and the first ideal one.  
(1)  
GE=Gain Error: deviation between the last ideal  
transition and the last actual one.  
DLE=Differential Linearity Error: maximum devia-  
tion between actual steps and the ideal one.  
ILE  
OE  
ILE=Integral Linearity Error: maximum deviation  
between any actual transition and the end point  
correlation line.  
DLE  
1 LSB (ideal)  
V
(LSB  
)
in  
ideal  
0
1
2
3
4
5
6
7
253 254 255 256  
V
V
DDA  
SSA  
126/131  
ST72141K2-Auto  
11 GENERAL INFORMATION  
11.1 PACKAGE CHARACTERISTICS  
11.1.1 Package Mechanical Data  
Figure 74. 34-Pin Plastic Small Outline Package, Shrink 300-mil Width  
mm  
inches  
Dim.  
h x 45°  
Min  
Typ Max Min Typ Max  
L
A
2.464  
2.642 0.097  
0.292 0.005  
0.483 0.014  
0.318 0.009  
18.059 0.698  
7.595 0.292  
0.104  
0.012  
0.019  
0.013  
0.711  
0.299  
A
C
A1  
A1 0.127  
α
B
C
D
E
e
0.356  
0.231  
17.729  
7.417  
e
B
D
1.016  
0.040  
H
h
α
L
10.160  
0.635  
0°  
10.414 0.400  
0.737 0.025  
0.410  
0.029  
8°  
E
H
8°  
0°  
0.610  
1.016 0.024  
0.040  
Number of Pins  
N
34  
®
11.2 ECOPACK  
11.3 ORDERING INFORMATION  
Transfer of Customer Code  
In order to meet environmental requirements, ST  
offers these devices in ECOPACK packages.  
®
Customer code is made up of the ROM contents  
and the list of the selected options (if any). The  
ROM contents are to be sent on diskette, or by  
electronic means, with the hexadecimal file gener-  
ated by the development tool. All unused bytes  
must be set to FFh.  
These packages have a lead-free second level in-  
terconnect. The category of second level intercon-  
nect is marked on the package and on the inner  
box label, in compliance with JEDEC Standard  
JESD97. The maximum ratings related to solder-  
ing conditions are also marked on the inner box la-  
bel.  
The selected options are communicated to STMi-  
croelectronics using the correctly completed  
ST72141K2-Auto MICROCONTROLLER OP-  
TION LIST on page 129 appended.  
®
ECOPACK is an ST trademark. ECOPACK spec-  
ifications are available at www.st.com.  
The STMicroelectronics Sales Organization will be  
pleased to provide detailed information on con-  
tractual points.  
127/131  
ST72141K2-Auto  
Figure 75. OTP User Programmable Device Types  
R E  
DEVICE  
®
E = Lead-free (ECOPACK )  
Conditioning options:  
R = Tape and Reel (left blank if Tube)  
ST72T141K2MA  
Figure 76. FASTROM Device Types  
XXX R E  
DEVICE  
/
®
E = Lead-free (ECOPACK )  
Conditioning options:  
R = Tape and Reel (left blank if Tube)  
Code name (defined by STMicroelectronics)  
(denotes ROM code, package, and temperature range)  
ST72P141K2  
128/131  
ST72141K2-Auto  
ORDERING INFORMATION (Cont’d)  
ST72141K2-Auto MICROCONTROLLER OPTION LIST  
Customer . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
Address  
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
Contact  
Phone No . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
STMicroelectronics references  
Device:  
ST72141K2  
SO34  
Package:  
Temperature Range:  
-40 to 85°C  
Conditioning:  
[ ] Tube  
[ ] Enabled  
[ ] No  
[ ] Tape & Reel  
[ ] Disabled  
Readout Protection:  
Special Marking:  
[ ] Yes “_ _ _ _ _ _ _ _ _ _ _ _ _ ”  
Authorized characters are letters, digits, '.', '-', '/' and spaces only.  
Maximum character count for SO34 package: 13.  
Comments :  
Notes  
Signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .  
129/131  
ST72141K2-Auto  
12 SUMMARY OF CHANGES  
Description of the changes between the current release of the specification and the previous one.  
Date  
Revision  
Main Changes  
Initial release of ST7214K2-Auto datasheet  
The ST72141K2-Auto datasheet was created from the ST72141K datasheet, revision 1.8  
dated October 2001, with the following changes:  
Changed document title and description on page 1  
Memories on page 1: Removed ROM  
Removed SDIP32 package outline from page 1  
Device Summary on page 1: Removed SDIP32 package and -40 to 125°C temperature  
range  
Section 1.2 PIN DESCRIPTION: Removed 32-pin SDIP package pinout  
Table 1 SO34 Device Pin Description on page 7: Removed SDIP32 column  
Table 3 Hardware Register Map on page 11: Modified WDGSR reset status and changed  
Read only to R/W  
Table 12 ZVD and CPB Edge Selection Bits on page 45: Updated with corrections to ZVD  
and CPB figures for ZVD = 1  
Added Related Documentation on page 73  
Section 8.2.3 Functional Description: Replaced 500ns with 30µs at end of second paragraph  
to be in line with spec given in Section 10.6.2 RESET Sequence Manager  
STATUS REGISTER (SR) on page 75: Modified reset value  
Section 8.3.3.3 Input Capture: Replaced “see figure 5” with “see Figure 48” in second para-  
graph  
23-Nov-2007  
1
Section 9.1.4 Indexed (No Offset, Short, Long): Replaced “The indirect addressing mode”  
with “The indexed addressing mode” in second paragraph  
Thermal Characteristics on page 117: Removed SDIP32 package from package thermal re-  
sistance ratings  
Section 10.2 RECOMMENDED OPERATING CONDITIONS: Removed 0 to 70°C and -40 to  
125°C versions from ambient temperature range  
Section 11.1.1 Package Mechanical Data: Removed 32-pin SDIP package  
Added Section 11.2 ECOPACK®  
Section 11.3 ORDERING INFORMATION: Removed figure ROM Factory Coded Device  
Types  
Figure 75.OTP User Programmable Device Types: Modified product code structure  
Added Figure 76.FASTROM Device Types  
ST72141K2-Auto MICROCONTROLLER OPTION LIST on page 129: Removed references  
to SDIP32 and DIP32 packages; removed -40 to 125°C temperature range  
Updated disclaimer on last page to include mention about use of ST products in automotive  
applications  
130/131  
ST72141K2-Auto  
Please Read Carefully:  
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the  
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any  
time, without notice.  
All ST products are sold pursuant to ST’s terms and conditions of sale.  
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no  
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.  
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this  
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products  
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such  
third party products or services or any intellectual property contained therein.  
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED  
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED  
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS  
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.  
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZED ST REPRESENTATIVE, ST PRODUCTS ARE NOT  
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE  
SUSTAINING APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN  
PERSONAL INJURY, DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT  
SPECIFIED AS "AUTOMOTIVE GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.  
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void  
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any  
liability of ST.  
ST and the ST logo are trademarks or registered trademarks of ST in various countries.  
Information in this document supersedes and replaces all information previously supplied.  
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.  
© 2007 STMicroelectronics - All rights reserved  
STMicroelectronics group of companies  
Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan -  
Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America  
www.st.com  
131/131  

相关型号:

ST72T212

REAL-TIME DEVELOPMENT TOOLS FOR THE ST7 MCU FAMILY
STMICROELECTR

ST72T212G2

8-BIT MICROCONTROLLER (MCU) WITH 4 TO 8K ROM/OTP/EPROM. 256 BYTES RAM. ADC. WGD. TIMERS. SPI - SO28. SDIP32
ETC

ST72T212G2B3

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI AND 1 OR 2 TIMERS
STMICROELECTR

ST72T212G2B6

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI AND 1 OR 2 TIMERS
STMICROELECTR

ST72T212G2M3

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI AND 1 OR 2 TIMERS
STMICROELECTR

ST72T212G2M3/TR

8-BIT MICROCONTROLLER (MCU) WITH 4 TO 8K ROM/OTP/EPROM. 256 BYTES RAM. ADC. WGD. TIMERS. SPI - SO28. SDIP32
ETC

ST72T212G2M6

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI AND 1 OR 2 TIMERS
STMICROELECTR

ST72T213

REAL-TIME DEVELOPMENT TOOLS FOR THE ST7 MCU FAMILY
STMICROELECTR

ST72T213G1

8-BIT MICROCONTROLLER (MCU) WITH 4 TO 8K ROM/OTP/EPROM. 256 BYTES RAM. ADC. WGD. TIMERS. SPI - SO28. SDIP32
ETC

ST72T213G1B3

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI AND 1 OR 2 TIMERS
STMICROELECTR

ST72T213G1B3XXX

暂无描述
STMICROELECTR

ST72T213G1B6

8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM, 256 BYTES RAM, ADC, WDG, SPI AND 1 OR 2 TIMERS
STMICROELECTR