ST ST72101, ST72212, ST72213 User Manual

查询ST72101G1供应商
ST72101/ST72212/ST72213
8-BIT MCU WITH 4 TO 8K ROM/OTP/EPROM,
256 BYTES RAM, ADC, WDG, SPI AND 1 OR 2 TIMERS
DATASHEET
User Program Memory (ROM/OTP/EPROM):
4 to8K bytes
Data RAM: 256 bytes, including 64 bytes of
Master Resetand Power-On Reset
Run, Wait, Slow, Halt and RAM Retention
modes
22 multifunctionalbidirectional I/O lines:
– 22 programmable interrupt inputs – 8 high sinkoutputs – 6 analog alternateinputs – 10 to 14 alternate functions – EMI filtering
Programmable watchdog (WDG)
One or two 16-bit Timers, each featuring:
– 2 Input Captures – 2 Output Compares – External Clock input (on Timer A only) – PWM and Pulse Generator modes
Synchronous Serial Peripheral Interface (SPI)
8-bit Analog-to-Digital converter (6 channels)
(ST72212 and ST72213 only)
8-bit Data Manipulation
63 Basic Instructions
17 mainAddressing Modes
8 x8 Unsigned Multiply Instruction
True BitManipulation
Complete Development Support on PC/DOS-
(See ordering information at the end of datasheet)
WINDOWSTMReal-Time Emulator
Full Software Package on DOS/WINDOWS
TM
(C-Compiler, Cross-Assembler, Debugger)
Device Summary
Features ST72101G1 ST72101G2 ST72213G1 ST72212G2
Program Memory- bytes 4K 8K 4K 8K RAM (stack) - bytes 256 (64) 16-bit Timers one one one two ADC no no yes yes Other Peripherals Watchdog, SPI Operating Supply 3 to 5.5 V CPU Frequency 8MHz max (16MHz oscillator) - 4MHz max over 85°C Temperature Range - 40°C to + 125°C Package SO28 - SDIP32
September 1999 1/84
PSDIP32
CSDIP32W
SO28
Rev. 1.7
1
Table of Contents
1 GENERAL DESCRIPTION . . . . . . ................................................ 4
1.1 INTRODUCTION . . . . . . . . . . . . ............................................. 4
1.2 PIN DESCRIPTION . . ..................................................... 5
1.3 EXTERNAL CONNECTIONS . .. . . . . . . . . . . . . . . . . . . .. . . . . . . .. . . . . . . . . ......... 9
1.4 MEMORY MAP . . . . . .. . . . ............................................... 10
2 CENTRAL PROCESSING UNIT . . ............................................... 13
2.1 INTRODUCTION . . . . . . . . . . . . ............................................13
2.2 MAIN FEATURES . . . . . . . . . . . . . . . . . . . . . . . . . .............................. 13
2.3 CPU REGISTERS . . . .................................................... 13
3 CLOCKS, RESET, INTERRUPTS & POWER SAVING MODES . . . . . .. . . . . . . ...........16
3.1 CLOCK SYSTEM . . . . . .. . . . . . ............................................16
3.1.1 General Description . . . .. . ...........................................16
3.2 RESET . . . . . . . . . . . . .. . . . . . . .. . . . . . . . . . . . . .............................. 17
3.2.1 Introduction . . . .................................................... 17
3.2.2 External Reset . . . . . . ...............................................17
3.2.3 Reset Operation . . . . . . . . . . . . . . . . . . . . . . . . . ........................... 17
3.2.4 Power-on Reset .................................................... 17
3.3 INTERRUPTS . . . .. . . . . . .. . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . .. . . . . . . .. . . . . . . 18
3.4 POWER SAVING MODES . .. . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . .. . . . . . . ........ 21
3.4.1 Introduction . . . .................................................... 21
3.4.2 Slow Mode . . .. . . . . . . . . . . . . . . . . . . . ................................. 21
3.4.3 Wait Mode . . . . . . . . . . . . . . .. ........................................ 21
3.4.4 Halt Mode . . . . . .................................................... 22
3.5 MISCELLANEOUS REGISTER . . . . .. . . . . . .................................. 23
4 ON-CHIP PERIPHERALS . . . . . . . . . . . ...........................................24
4.1 I/O PORTS . . . . . . . . .. . . . . . . . . ...........................................24
4.1.1 Introduction . . . .................................................... 24
4.1.2 Functional Description . . . . ...........................................24
4.1.3 I/O Port Implementation . . . . . . . . . . . . . . . . . . . ........................... 25
4.1.4 Register Description . . . . . . ...........................................28
4.2 WATCHDOG TIMER (WDG) . . . . . . .. . . . . . . .. . . .. . . .. . . . . . . . . . . . . . . . .. . . . . . . 30
4.2.1 Introduction . . . .................................................... 30
4.2.2 Main Features . .. . . . ...............................................30
4.2.3 Functional Description . . . . ...........................................31
4.2.4 Low Power Modes . . . ............................................... 31
4.2.5 Interrupts . . . . . .. . . . . . . . . . .. . . . . . . ................................. 31
4.2.6 Register Description . . . . . . ...........................................31
4.3 16-BIT TIMER . . . . . . . . . . . . . . . . . . ........................................32
4.3.1 Introduction . . . .................................................... 32
4.3.2 Main Features . .. . . . ...............................................32
4.3.3 Functional Description . . . . ...........................................32
4.3.4 Low Power Modes . . ............................................... 43
4.3.5 Interrupts . . .. . .................................................... 43
4.3.6 Register Description . . . . . . ...........................................44
95
2/84
2
Table of Contents
4.4 SERIAL PERIPHERAL INTERFACE (SPI) . . . . . . . . . . . . . . . .. . . . . . . . . ...........49
4.4.1 Introduction . . . .................................................... 49
4.4.2 Main Features . .. . . . ...............................................49
4.4.3 General description . . . . . .. . . . . . . . .. . . .. . . . . . . . . . .. . . . . . . . . . . . . . . . . . . 49
4.4.4 Functional Description . . . . ...........................................51
4.4.5 Low Power Modes . . . ............................................... 58
4.4.6 Interrupts . . .. . .................................................... 58
4.4.7 Register Description . . . . . . ...........................................59
4.5 8-BIT A/D CONVERTER (ADC) . . . . . .. . . . . . . . . . . . ........................... 62
4.5.1 Introduction . . . .................................................... 62
4.5.2 Main Features . .. . . . ...............................................62
4.5.3 Functional Description . . . . ...........................................63
4.5.4 Low Power Modes . . . ............................................... 63
4.5.5 Interrupts . . . . . .. . . . . . . . . . .. . . . . . . ................................. 63
4.5.6 Register Description . . . . . . ...........................................64
5 INSTRUCTION SET . . . . . . . . . . . . . . . . . . ........................................ 65
5.1 ST7 ADDRESSING MODES . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 65
5.1.1 Inherent . . . . . . . . . . . ...............................................66
5.1.2 Immediate . .. . . . . . . . . . . . . . . . . . . .. . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.1.3 Direct . ........................................................... 66
5.1.4 Indexed (No Offset, Short, Long) . . . . . . . . . . . . ........................... 66
5.1.5 Indirect (Short, Long) . . . . .. . . . . . . . . . .. . . . . . . . . . . . .. . . .. . . . . . . . . . . . . . . 66
5.1.6 Indirect Indexed (Short,Long) . ........................................67
5.1.7 Relative mode (Direct,Indirect) . . . .. . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . . . . . . 67
5.2 INSTRUCTION GROUPS . . . . . . . . . . . . . . . . ................................. 68
6 ELECTRICALCHARACTERISTICS . . . . . . . . . . . . . . . . .............................. 71
6.1 ABSOLUTE MAXIMUM RATINGS . . . ........................................71
6.2 RECOMMENDED OPERATING CONDITIONS . . ............................... 72
6.3 DC ELECTRICAL CHARACTERISTICS . . . . . . . . . . . . . .. . . . . . . . . . . . . ...........73
6.4 RESET CHARACTERISTICS . . . . . . . . . ..................................... 74
6.5 OSCILLATOR CHARACTERISTICS . . . .. . . . . . . .............................. 74
6.6 A/D CONVERTERCHARACTERISTICS (ST72212 AND ST72213ONLY) . . . ........ 75
6.7 SPI CHARACTERISTICS . . ...............................................77
7 GENERAL INFORMATION . . . . . . . . . . ........................................... 80
7.1 EPROM ERASURE . . .. . . . . . . . . . . . . .. . . . . . ............................... 80
7.2 PACKAGE MECHANICALDATA . . . . . . . . . . . . .. . . . ........................... 80
7.3 ORDERING INFORMATION . . . . . .. . . . . . . .................................. 82
7.3.1 Transfer Of CustomerCode . . . . . . . . . . . .. . . .. . . . . . . . . . . . ............... 82
8 SUMMARY OF CHANGES . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
3/84
3
ST72101/ST72212/ST72213
1 GENERAL DESCRIPTION
1.1 INTRODUCTION
The ST72101, ST72213 and ST72212 HCMOS Microcontroller Units are members of the ST7 family. These devices are based on an industry­standard 8-bit core and feature an enhanced instruction set. They normally operate ata 16MHz oscillator frequency. Under software control, the ST72101, ST72213 and ST72212 may be placed in either WAIT, SLOW or HALT modes, thus reducing power consumption. The enhanced instruction set and addressing modes afford real programming potential. In addition to standard 8-bit data management, the ST72101, ST72213
unsigned multiplication and indirect addressing modes on the whole memory. The devices include an on-chip oscillator, CPU, program memory (ROM/OTP/EPROM versions), RAM, 22 I/O lines and the following on-chip peripherals: Analog-to­Digital Converter (ADC) with 6 multiplexed analog inputs (ST72212 and ST72213 only), industry standard synchronous SPI serial interface, digital Watchdog, one or two independent 16-bit Timers, one featuring an External Clock Input, and both featuring Pulse Generator capabilities, 2 Input Captures and 2 Output Compares.
and ST72212 feature true bit manipulation, 8x8
Figure 1. ST72101, ST72213 and ST72212 Block Diagram
Internal
OSCIN
OSCOUT
RESET
OSC
CONTROL
8-BIT CORE
ALU
CLOCK
ADDRESSAND DATA BUS
PORT A
SPI
PORT B
TIMER A
PA0 -> PA7
(8 bits)
PB0 -> PB7
(8 bits)
4/84
4
PROGRAM
MEMORY
(4 - 8K Bytes)
(256 Bytes)
V
DD
V
SS
1) ST72213 and ST72212 only
2) ST72212 only
RAM
POWER
SUPPLY
PORT C
8-BIT ADC
TIMER B
WATCHDOG
PC0 -> PC5
(6 bits)
1)
2)
1.2 PIN DESCRIPTION
ST72101/ST72212/ST72213
Figure 2. ST72212 Pinout (SO28)
RESET
OSCIN
OSCOUT
SS/PB7
SCK/PB6 MISO/PB5 MOSI/PB4
OCMP2_A/PB3
ICAP2_A/PB2
OCMP1_A/PB1
ICAP1_A/PB0
AIN5/EXTCLK_A/PC5
AIN4/OCMP2_B/PC4
AIN3/ICAP2_B/PC3
1) VPPonEPROM/OTP only
1 2 3 4 5 6 7 8 9 10 11 12 13 14
28 27 26 25 24 23 22 21 20 19 18 17 16 15
Figure 3. ST72213 Pinout (SO28)
RESET
OSCIN
OSCOUT
SS/PB7
SCK/PB6 MISO/PB5 MOSI/PB4
OCMP2_A/PB3
ICAP2_A/PB2
OCMP1_A/PB1
ICAP1_A/PB0
AIN5/EXTCLK_A/PC5
AIN4/PC4 AIN3/PC3
1) VPPon EPROM/OTPonly
1 2 3 4 5 6 7 8 9 10 11 12 13 14
28 27 26 25 24 23 22 21 20 19 18 17 16 15
V
DD
V
SS
TEST/V PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 PC0/ICAP1_B/AIN0 PC1/OCMP1_B/AIN1 PC2/CLKOUT/AIN2
1)
PP
V
DD
V
SS
TEST/V PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 PC0/AIN0 PC1/AIN1 PC2/CLKOUT/AIN2
1)
PP
Figure 5. ST72212 Pinout (SDIP32)
V
RESET
OSCIN
OSCOUT
SS/PB7
SCK/PB6 MISO/PB5 MOSI/PB4
NC NC
OCMP2_A/PB3
ICAP2_A/PB2
OCMP1_A/PB1
ICAP1_A/PB0
AIN5/EXTCLK_A/PC5
AIN4/OCMP2_B/PC4
AIN3/ICAP2_B/PC3
1) VPPon EPROM/OTP only
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
32 31 30
29 28 27 26 25 24 23 22 21 20 19 18 17
V TEST/V PA0 PA1 PA2 PA3 NC NC PA4 PA5 PA6 PA7 PC0/ICAP1_B/AIN0 PC1/OCMP1_B/AIN1 PC2/CLKOUT/AIN2
Figure 6. ST72213 Pinout (SDIP32)
V
RESET
OSCIN
OSCOUT
SS/PB7
SCK/PB6 MISO/PB5 MOSI/PB4
NC NC
OCMP2_A/PB3
ICAP2_A/PB2
OCMP1_A/PB1
ICAP1_A/PB0
AIN5/EXTCLK_A/PC5
AIN4/PC4 AIN3/PC3
1) VPPonEPROM/OTP only
1 2 3 4 5 6 7 8
9 10 11 12 13 14
15
32 31
TEST/V
30 29
PA0 PA1
28
PA2
27 26
PA3
25
NC
24
NC
23
PA4
22
PA5
21
PA6
20
PA7
19
PC0/AIN0
18
PC1/AIN1
1716
PC2/CLKOUT/AIN2
V
DD SS
1)
PP
DD
SS
1)
PP
Figure 4. ST72101 Pinout (SO28)
RESET
OSCIN
OSCOUT
SS/PB7
SCK/PB6 MISO/PB5 MOSI/PB4
OCMP2_A/PB3
ICAP2_A/PB2
OCMP1_A/PB1
ICAP1_A/PB0
EXTCLK_A/PC5
PC4 PC3
1) VPPon EPROM/OTP only
1 2 3 4 5 6 7 8 9 10 11 12 13
14
28 27 26 25 24 23 22 21 20 19 18 17 16 15
V
DD
V
SS
TEST/V PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 PC0 PC1 PC2/CLKOUT
1)
PP
Figure 7. ST72101 Pinout (SDIP32)
32
RESET
OSCIN
OSCOUT
SS/PB7
SCK/PB6 MISO/PB5 MOSI/PB4
NC NC
OCMP2_A/PB3
ICAP2_A/PB2
OCMP1_A/PB1
ICAP1_A/PB0
EXTCLK_A/PC5
PC4 PC3
1) VPPon EPROM/OTPonly
1 2 3 4 5 6 7 8
9 10 11 12 13 14
15
31 30
29 28 27 26 25 24 23 22 21 20 19 18 1716
V V TEST/V PA0 PA1 PA2 PA3
NC NC PA4 PA5 PA6 PA7 PC0 PC1 PC2/CLKOUT
DD SS
1)
PP
5/84
5
ST72101/ST72212/ST72213
Table 1. ST72212 Pin Configuration
Pin n°
SDIP32
Pin n °
SO28
Pin Name Type Description Remarks
1 1 RESET I/O Bidirectional. Active low. Top priority non maskable interrupt. 22OSCIN I 3 3 OSCOUT O
Input/Output Oscillator pin. These pins connect a parallel-resonant crystal, or an external source to the on-chip oscillator.
4 4 PB7/SS I/O Port B7 or SPI Slave Select (active low) External Interrupt: EI1 5 5 PB6/SCK I/O Port B6 or SPI Serial Clock External Interrupt: EI1 6 6 PB5/MISO I/O Port B5 or SPI Master In/ Slave Out Data External Interrupt: EI1 7 7 PB4/MOSI I/O Port B4 or SPI Master Out / Slave In Data External Interrupt: EI1 8 NC Not Connected
9 NC Not Connected 10 8 PB3/OCMP2_A I/O Port B3 or TimerA Output Compare 2 External Interrupt: EI1 11 9 PB2/ICAP2_A I/O Port B2 or TimerA Input Capture 2 External Interrupt: EI1 12 10 PB1/OCMP1_A I/O Port B1 or TimerA Output Compare 1 External Interrupt: EI1 13 11 PB0/ICAP1_A I/O Port B0 or TimerA Input Capture 1 External Interrupt: EI1 14 12 PC5/EXTCLK_A/AIN5 I/O PortC5orTimerA InputClockorADCAnalog Input5 External Interrupt: EI1
15 13 PC4/OCMP2_B/AIN4 I/O 16 14 PC3 /IC A P2 _ B /AIN 3 I/O
PortC4orTimerB OutputCompare2orADCAnalog Input 4
Port C3 orTimerB InputCapture 2 orADC Analog Input 3
External Interrupt: EI1 External Interrupt: EI1
Port C2or InternalClockFrequency Outputor ADC
17 15 PC2/CLKOUT/AIN2 I/O
Analog Input 2. Clockout is driven by Bit 5 of the
External Interrupt: EI1
miscellaneous register.
18 16 PC1/OCMP1_B/AIN1 I/O 19 17 PC0 /IC A P1 _ B /AIN 0 I/O
PortC1orTimerB OutputCompare1orADCAnalog Input 1
Port C0 orTimerB InputCapture 1 orADC Analog Input 0
External Interrupt: EI1 External Interrupt: EI1
20 18 PA7 I/O Port A7, High Sink External Interrupt: EI0 21 19 PA6 I/O Port A6, High Sink External Interrupt: EI0 22 20 PA5 I/O Port A5, High Sink External Interrupt: EI0 23 21 PA4 I/O Port A4, High Sink External Interrupt: EI0 24 NC Not Connected 25 NC Not Connected 26 22 PA3 I/O Port A3, High Sink External Interrupt: EI0 27 23 PA2 I/O Port A2, High Sink External Interrupt: EI0 28 24 PA1 I/O Port A1, High Sink External Interrupt: EI0 29 25 PA0 I/O Port A0, High Sink External Interrupt: EI0
30 26 TEST/V 31 27 V
32 28 V
Note 1:VPPon EPROM/OTP only
SS DD
PP
(1)
Test mode pin (should be tied low in user mode). In the EPROM program-
I/S
ming mode, this pin acts as the programming voltage input V
S Ground S Main power supply
PP.
6/84
6
Table 2. ST72213 Pin Configuration
ST72101/ST72212/ST72213
Pin n°
SDIP32
Pin n°
SO28
Pin Name Type Description Remarks
1 1 RESET I/O
2 2 OSCIN I
3 3 OSCOUT O
Bidirectional. Active low. Top priority non maskable interrupt.
Input/Output Oscillator pin. These pins connect a parallel-resonant crystal, oran external source to the on-chip oscillator.
4 4 PB7/SS I/O Port B7 orSPI Slave Select (active low) External Interrupt: EI1
5 5 PB6/SCK I/O Port B6 orSPI Serial Clock External Interrupt: EI1
6 6 PB5/MISO I/O Port B5 orSPI Master In/ Slave Out Data External Interrupt: EI1
7 7 PB4/MOSI I/O Port B4 orSPI Master Out / Slave In Data External Interrupt: EI1
8 NC Not Connected
9 NC Not Connected 10 8 PB3/OCMP2_A I/O Port B3 or TimerA Output Compare 2 External Interrupt: EI1 11 9 PB2/ICAP2_A I/O Port B2 orTimerA Input Capture 2 External Interrupt: EI1 12 10 PB1/OCMP1_A I/O Port B1 or TimerA Output Compare 1 External Interrupt: EI1 13 11 PB0/ICAP1_A I/O Port B0 orTimerA Input Capture 1 External Interrupt: EI1
14 12 PC5/EXTCLK_A/AIN5 I/O
Port C5 orTimerA Input Clock or ADC Analog Input 5
External Interrupt: EI1
15 13 PC4/AIN4 I/O Port C4 or ADC Analog Input 4 External Interrupt: EI1 16 14 PC3/AIN3 I/O Port C3 or ADC Analog Input 3 External Interrupt: EI1
Port C2 orInternal Clock Frequency Output or
17 15 PC2/CLKOUT/AIN2 I/O
ADC Analog Input 2. Clockout is driven by Bit 5
External Interrupt: EI1
of the miscellaneous register.
18 16 PC1/AIN1 I/O Port C1 or ADC Analog Input 1 External Interrupt: EI1 19 17 PC0/AIN0 I/O Port C0 or ADC Analog Input 0 External Interrupt: EI1 20 18 PA7 I/O Port A7, High Sink External Interrupt: EI0 21 19 PA6 I/O Port A6, High Sink External Interrupt: EI0 22 20 PA5 I/O Port A5, High Sink External Interrupt: EI0 23 21 PA4 I/O Port A4, High Sink External Interrupt: EI0 24 NC Not Connected 25 NC Not Connected 26 22 PA3 I/O Port A3, High Sink External Interrupt: EI0 27 23 PA2 I/O Port A2, High Sink External Interrupt: EI0 28 24 PA1 I/O Port A1, High Sink External Interrupt: EI0 29 25 PA0 I/O Port A0, High Sink External Interrupt: EI0
30 26 TEST/V 31 27 V
32 28 V
Note 1:VPPon EPROM/OTP only
SS DD
PP
(1)
Test mode pin (should be tied low in user mode). In the EPROM pro-
I/S
gramming mode, this pin acts asthe programming voltage input V
S Ground S Main power supply
PP.
7/84
7
ST72101/ST72212/ST72213
Table 3. ST72101 Pin Configuration
Pin n°
SDIP32
Pinn°
SO28
Pin Name Type Description Remarks
1 1 RESET I/O Bidirectional. Active low. Top priority non maskable interrupt.
2 2 OSCIN I
3 3 OSCOUT O
Input/Output Oscillator pin. These pins connect a parallel-resonant crystal, or an external source to the on-chip oscillator.
4 4 PB7/SS I/O Port B7 orSPI Slave Select (active low) External Interrupt: EI1
5 5 PB6/SCK I/O Port B6 orSPI Serial Clock External Interrupt: EI1
6 6 PB5/MISO I/O Port B5 orSPI Master In/ Slave Out Data External Interrupt: EI1
7 7 PB4/MOSI I/O Port B4 orSPI Master Out / Slave In Data External Interrupt: EI1
8 NC Not Connected
9 NC Not Connected 10 8 PB3/OCMP2_A I/O Port B3 orTimerA Output Compare 2 External Interrupt: EI1 11 9 PB2/ICAP2_A I/O Port B2 orTimerA Input Capture 2 External Interrupt: EI1 12 10 PB1/OCMP1_A I/O Port B1 orTimerA Output Compare 1 External Interrupt: EI1 13 11 PB0/ICAP1_A I/O Port B0 orTimerA Input Capture 1 External Interrupt: EI1 14 12 PC5/EXTCLK_A I/O Port C5 or TimerA Input Clock External Interrupt: EI1 15 13 PC4 I/O Port C4 External Interrupt: EI1 16 14 PC3 I/O Port C3 External Interrupt: EI1
17 15 PC2/CLKOUT I/O
Port C2 or Internal Clock Frequency Output.Clockout is driven by MCO bit of the miscellaneous register.
External Interrupt: EI1
18 16 PC1 I/O Port C1 External Interrupt: EI1 19 17 PC0 I/O Port C0 External Interrupt: EI1 20 18 PA7 I/O Port A7, High Sink External Interrupt: EI0 21 19 PA6 I/O Port A6, High Sink External Interrupt: EI0 22 20 PA5 I/O Port A5, High Sink External Interrupt: EI0 23 21 PA4 I/O Port A4, High Sink External Interrupt: EI0 24 NC Not Connected 25 NC Not Connected 26 22 PA3 I/O Port A3, High Sink External Interrupt: EI0 27 23 PA2 I/O Port A2, High Sink External Interrupt: EI0 28 24 PA1 I/O Port A1, High Sink External Interrupt: EI0 29 25 PA0 I/O Port A0, High Sink External Interrupt: EI0
30 26 TEST/V 31 27 V
32 28 V
Note 1:V
on EPROM/OTP only.
PP
SS DD
PP
(1)
Test mode pin (should be tied low in user mode). In the EPROM programming
I/S
mode, this pin acts as the programming voltage input V
PP.
S Ground S Main power supply
8/84
8
1.3 EXTERNAL CONNECTIONS
ST72101/ST72212/ST72213
The following figure shows the recommended ex­ternal connections for the device.
The VPPpin is only used for programming OTP and EPROM devices and must betied to ground in user mode.
The 10 nF and 0.1 µF decoupling capacitors on the power supply lines are a suggested EMC per­formance/cost tradeoff.
Figure 8. Recommended External Connections
V
DD
EXTERNAL RESET CIRCUIT
10nF
+
V
DD
0.1µF
0.1µF
The external reset network is intended to protect the device against parasitic resets, especially in noisy environments.
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.
V
PP
V
4.7K
DD
V
SS
RESET
0.1µF
See Clocks Section
Or configure unused I/O ports by software as input with pull-up
V
10K
DD
OSCIN
OSCOUT
Unused I/O
9/84
9
ST72101/ST72212/ST72213
1.4 MEMORY MAP Figure 9. Memory Map
0000h
007Fh 0080h
017Fh
0180h
DFFFh
E000h
F000h
FFDFh
FFE0h
FFFFh
HW Registers
(see Table 5)
256 Bytes RAM
Reserved
8K Bytes
Program Memory
4K Bytes
Program Memory
Interrupt & Reset Vectors
(see Table 4)
0080h
Short Addressing RAM (zero page)
00FFh 0100h
16-bit Addressing
013Fh 0140h
64 Bytes Stack or
16-bit Addressing RAM
017Fh
RAM
Table 4. 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
TIMER B Interrupt Vector (ST72212 only)
TIMER A Interrupt Vector
External Interrupt Vector EI1 External Interrupt Vector EI0
TRAP (software) Interrupt Vector
Not Used Not Used Not Used Not Used Not Used Not Used Not Used
Not Used
SPI Interrupt Vector
Not Used
RESET Vector
10/84
10
Internal Interrupt
Internal Interrupt Internal Interrupt
External Interrupt External Interrupt
CPU Interrupt
Table 5. Hardware Register Memory Map
Address
Block Name
Register
Label
ST72101/ST72212/ST72213
Register name Reset Status Remarks
0000h 0001h 0002h
0003h Reserved Area (1 Byte) 0004h
0005h 0006h
0007h Reserved Area (1 Byte) 0008h
0009h 000Ah
000Bh to 001Fh
0020h MISCR Miscellaneous Register 00h R/W 0021h
0022h 0023h
0024h WDG WDGCR Watchdog Control register 7Fh R/W 0025h to
0030h 0031h
0032h 0033h 0034h-0035h
0036h-0037h
0038h-0039h
003Ah-003Bh
003Ch-003Dh
003Eh-003Fh
Port C
Port B
Port A
SPI
Timer A
PCDR PCDDR PCOR
PBDR PBDDR PBOR
PADR PADDR PAOR
SPIDR SPICR SPISR
TACR2 TACR1 TASR TAIC1HR TAIC1LR TAOC1HR TAOC1LR TACHR TACLR TAACHR TAACLR TAIC2HR TAIC2LR TAOC2HR TAOC2LR
Data Register Data Direction Register Option Register
Data Register Data Direction Register Option Register
Data Register Data Direction Register Option Register
Reserved Area (21 Bytes)
Data I/O Register Control Register Status Register
Reserved Area (12 Bytes)
Control Register2 Control Register1 Status Register Input Capture1 High Register Input Capture1 Low Register Output Compare1 High Register Output Compare1 Low Register Counter High Register Counter Low Register Alternate Counter High Register Alternate Counter Low Register Input Capture2 High Register Input Capture2 Low Register Output Compare2 High Register Output Compare2 Low Register
00h 00h 00h
00h 00h 00h
00h 00h 00h
xxh 0xh 00h
00h 00h 00h xxh xxh 80h
00h FFh FCh FFh FCh
xxh
xxh
80h
00h
R/W R/W R/W
R/W R/W R/W
R/W R/W R/W
R/W R/W
Read Only
R/W
R/W Read Only Read Only Read Only
R/W
R/W Read Only Read Only Read Only Read Only Read Only Read Only
R/W
R/W
0040h Reserved Area (1 Byte)
11/84
11
ST72101/ST72212/ST72213
Address
0041h 0042h 0043h 0044h-0045h
0046h-0047h
0048h-0049h
004Ah-004Bh
004Ch-004Dh
004Eh-004Fh
0050h to 006Fh
0070h 0071h
0072h to 007Fh
Block Name
Timer B
2)
ADC
1)
Register
Label
TBCR2 TBCR1 TBSR TBIC1HR TBIC1LR TBOC1HR TBOC1LR TBCHR TBCLR TBACHR TBACLR TBIC2HR TBIC2LR TBOC2HR TBOC2LR
ADCDR ADCCSR
Register name Reset Status Remarks
Control Register2 Control Register1 Status Register Input Capture1 High Register Input Capture1 Low Register Output Compare1 High Register Output Compare1 Low Register Counter High Register Counter Low Register Alternate Counter High Register Alternate Counter Low Register Input Capture2 High Register Input Capture2 Low Register Output Compare2 High Register Output Compare2 Low Register
Reserved Area (32 Bytes)
Data Register Control/Status Register
Reserved Area (14 Bytes)
00h 00h 00h xxh xxh 80h
00h FFh FCh FFh FCh
xxh
xxh
80h
00h
00h
00h
R/W
R/W Read Only Read Only Read Only
R/W
R/W Read Only Read Only Read Only Read Only Read Only Read Only
R/W
R/W
Read Only
R/W
Notes:
1. ST72212 only, reserved area for other devices.
2. ST72212 and ST72213 only, reserved otherwise.
12/84
12
2 CENTRAL PROCESSING UNIT
ST72101/ST72212/ST72213
2.1 INTRODUCTION
This CPU hasa full 8-bit architecture andcontains six internal registers allowing efficient 8-bit data manipulation.
2.2 MAIN FEATURES
63 basicinstructions
Fast 8-bit by 8-bit multiply
17 main addressing modes (with indirect
addressing mode)
Two 8-bit index registers
16-bit stackpointer
8 MHzCPU internal frequency
Low power modes
Maskable hardware interrupts
Non-maskable software interrupt
2.3 CPU REGISTERS
The 6 CPU registers shown in Figure 10 are not present in thememory mapping and are accessed by specificinstructions.
Figure 10. CPU Registers
70
RESET VALUE = XXh
70
RESET VALUE= XXh
70
RESET VALUE = XXh
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 andto manipulate data.
Index Registers (Xand Y)
In indexedaddressingmodes, 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.)
The Y register is notaffected by theinterrupt auto­matic procedures (notpushed toand popped from the stack).
Program Counter (PC)
The program counteris a16-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 CounterLow whichis the LSB) and PCH (Program Counter High which is the MSB).
ACCUMULATOR
X INDEX REGISTER
Y INDEX REGISTER
15 8
RESET VALUE= RESET VECTOR @ FFFEh-FFFFh
15
RESET VALUE = STACKHIGHER ADDRESS
PCH
RESET VALUE =
7
70
1C11HINZ
1X11X1XX
87 0
PCL
0
PROGRAM COUNTER
CONDITION CODE REGISTER
STACK POINTER
X = Undefined Value
13/84
13
ST72101/ST72212/ST72213
CENTRAL PROCESSING UNIT (Cont’d) CONDITION CODE REGISTER (CC)
Read/Write Reset Value: 111x1xxx
70
ter it and resetby the IRET instruction at theend of the interrupt routine. If the I bit is cleared by soft­ware inthe interrupt routine, pending interruptsare serviced regardless of the priority levelof the cur­rent interrupt routine.
111HINZC
The 8-bit Condition Code register contains the in­terrupt mask and four flags representative of the result of the instructionjust executed. This register can also be handled by the PUSH and POP in­structions.
These bits can be individually tested and/or con­trolled by specific instructions.
Bit 4 = H
Half carry
.
This bit isset byhardware when a carry occurs be­tween bits 3 and 4 of the ALU during an ADD or ADC instruction.Itis reset by hardware during the same instructions. 0: No half carry has occurred. 1: A half carry has occurred.
This bit is tested using the JRH or JRNH instruc­tion. The H bit is useful in BCD arithmetic subrou­tines.
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. 0: Interrupts are enabled. 1: Interrupts are disabled.
This bit is controlled by the RIM, SIM and IRET in­structions andis tested bythe JRM and JRNM in­structions.
Note: Interrupts requested while I is set are latched and can be processed when I is cleared. By default an interrupt routine is not interruptable because the I bit is set by hardware when you en-
Bit 2 = N
Negative
.
This bit is set and cleared by hardware.It is repre­sentative of the result sign of the last arithmetic, logical or data manipulation. It is a copy of the 7 bit of the result. 0:Theresult of the last operation is positiveor null. 1: The result of the last operation is negative
(i.e. the most significant bit is a logic 1).
This bit isaccessed by the JRMIand JRPL instruc­tions.
Bit 1 = Z
Zero
.
This bit is set and clearedby hardware. Thisbit in­dicates that the result of the last arithmetic, logical or data manipulation is zero. 0: The result of the last operation is different from
zero.
1: The result of the last operation is zero. This bit is accessed by the JREQ and JRNE test
instructions.
Bit 0 = C
Carry/borrow.
This bit is set and cleared by hardware and soft­ware. It indicates an overflow or anunderflow has occurred during the last arithmetic operation. 0: No overflowor underflow has occurred. 1: An overflow or underflow has occurred.
This bit is driven by the SCFand RCF instructions and tested by theJRC andJRNC instructions.It is also affected by the“bit test and branch”, shift and rotate instructions.
th
14/84
14
ST72101/ST72212/ST72213
CENTRAL PROCESSING UNIT (Cont’d) Stack Pointer (SP)
Read/Write Reset Value: 01 7Fh
15 8
00000001
70
0 1 SP5 SP4 SP3 SP2 SP1 SP0
The Stack Pointer is a 16-bit register which is al­ways pointingto the next free location in the stack. It isthen decremented after datahas been pushed onto the stack and incremented before data is popped from the stack (see Figure 11).
Since the stack is 64 bytes deep, the 10 most sig­nificant bits are forced by hardware. Following an MCU Reset, or after a Reset Stack Pointer instruc­tion (RSP), the Stack Pointer contains its reset val­ue (the SP5 to SP0 bits are set) which is the stack higher address.
The least significant byte of the Stack Pointer (called S) can be directly accessed by a LD in­struction.
Note: When the lower limit is exceeded, the Stack Pointer wraps around tothe stackupper limit, with­out indicating the stack overflow. The previously stored information is then overwritten and there­fore lost.The stackalso wrapsin caseof anunder­flow.
The stack is used to save the return address dur­ing a subroutine call and the CPU context during an interrupt.Theuser may also directly manipulate the stack by means of the PUSH and POP instruc­tions. In the case ofan interrupt, the PCLis stored at the first location pointed to by the SP. Then the other registers are stored in the next locations as shown in Figure 11.
– Whenan interrupt isreceived, the SP is decre-
mented and the context is pushed on the stack.
– Onreturn from interrupt, the SP is incremented
and thecontext is popped from the stack.
A subroutine call occupies twolocations and anin­terrupt five locations in the stack area.
Figure 11. Stack Manipulation Example
@ 0140h
SP
@ 017Fh
CALL
Subroutine
SP
PCH
PCL
Stack Lower Address = 0140h Stack Higher Address =
Interrupt
Event
SP
CC
A
X PCH PCL PCH PCL
017Fh
PUSH Y POP Y IRET
SP
Y
CC
A X
PCH
PCL
PCH
PCL
CC
A
X PCH PCL PCH
PCL
SP
PCH
PCL
RET
or RSP
SP
15/84
15
ST72101/ST72212/ST72213
3 CLOCKS, RESET, INTERRUPTS & POWER SAVING MODES
3.1 CLOCK SYSTEM
3.1.1 General Description
The MCU accepts either a Crystal or Ceramicres­onator, or an external clock signal to drive the in­ternal oscillator. The internal clock (f
rived fromthe external oscillator frequency (f
CPU
) is de-
OSC).
The external Oscillator clock is first divided by 2, and division factor of 32 can be applied if Slow Mode is selected by settingthe SMS bit in the Mis­cellaneous Register. This reduces the frequency of the f
; the clock signal is also routed to the
CPU
on-chip peripherals. The internal oscillator is designed to operate with
an AT-cut parallel resonant quartz crystal resona­tor in the frequency range specified for f
osc
.The
circuit shown in Figure 13 is recommended when using a crystal, and Table 6 lists the recommend­ed capacitance and feedback resistance values. The crystal and associated componentsshould be mounted as close as possible to the input pins in order to minimize output distortion and start-up stabilisation time.
Use of an external CMOS oscillator is recom­mended when crystals outside the specified fre­quency ranges are to be used.
Figure 12. External Clock Source Connections
OSCIN OSCOUT
NC
EXTERNAL
CLOCK
Figure 13. Crystal/CeramicResonator
OSCIN OSCOUT
Table 6. Recommended Values for 16 MHz
Crystal Resonator (C0<7pF)
R
SMAX
C
OSCIN
C
OSCOUT
40 60 150
56pF 47pF 22pF 56pF 47pF 22pF
C0: parasitic shunt capacitance of the quartz crys­tal.
R
er limit, see crystal specification).
C
OSCIN and OSCOUT, including the external ca-
: equivalent serialresistor of the crystal (up-
SMAX
OSCOUT,COSCIN
: maximum total capacitance on
pacitance plus the parasitic capacitance of the board and the device.
C
OSCIN
C
OSCOUT
Figure 14. Clock Prescaler Block Diagram
C
OSCIN
OSCIN
OSCOUT
C
OSCOUT
%2 % 16
f
CPU
to CPU and Peripherals
16/84
16
3.2 RESET
ST72101/ST72212/ST72213
3.2.1 Introduction
There are three sources of Reset: – RESET pin (externalsource) – Power-On Reset (Internal source) – WATCHDOG (Internal Source) The Reset Service Routine vectoris located at ad-
dress FFFEh-FFFFh.
3.2.2 External Reset
The RESET pin is both an input and an open-drain output with integrated pull-up resistor. When one of the internal Reset sources is active, the Reset pin is driven low , for a duration of t the whole application.
RESET,
to reset
3.2.3 Reset Operation
The duration of the Reset state is a minimum of 4096 internal CPU Clock cycles. During the Reset state, all I/Os take their reset value.
A Reset signal originating from an externalsource must have a duration of at least t
PULSE
in order to be recognised. This detection is asynchronous and therefore the MCU can enter Reset state even in Halt mode.
At the end of the Reset cycle, the MCU may be held in the Reset state by an External Reset sig­nal. The RESET pin may thus be used to ensure VDDhas risen to a point where theMCU can oper­ate correctly before the user program is run. Fol-
lowing a Reset event, or after exiting Halt mode, a 4096 CPU Clock cycle delay period is initiated in order to allow the oscillator to stabilise and to en­sure that recovery hastaken place from the Reset state.
In the high state, the RESET pin is connected in­ternally to a pull-up resistor (RON). This resistor can be pulled low by external circuitry to reset the device.
The RESET pin is an asynchronous signal which plays a majorrole in EMS performance. In a noisy environment, it is recommended to use the exter­nal connections shown in Figure8.
3.2.4 Power-on Reset
This circuit detects the ramping up of VDD, and generates a pulse that is used to reset the applica­tion (at approximately VDD= 2V).
Power-On Reset is designed exclusively to cope with power-up conditions, and should not be used in order to attempt to detect a drop in the power supply voltage.
Caution:
to re-initialize the Power-On Reset, the power supply must fall below approximately 0.8V (Vtn), prior to rising above 2V. If this condition is not respected, on subsequent power-upthe Reset pulse may not be generated. An external Reset pulse may be required to correctly reactivate the circuit.
Figure 15. Reset Block Diagram
OSCILLATOR
SIGNAL
RESET
V
DD
R
ON
TO ST7
RESET
INTERNAL RESET
COUNTER
POWER-ON RESET
WATCHDOG RESET
17/84
17
ST72101/ST72212/ST72213
3.3 INTERRUPTS
The ST7 coremaybe interruptedby one of two dif­ferent methods: maskable hardware interrupts as listed in the Interrupt Mapping Table and a non­maskable software interrupt (TRAP). The Interrupt processing flowchartis shown in Figure16. The maskable interrupts mustbe enabled clearing the I bitin order to be serviced. However, disabled interrupts may be latched and processed when they are enabled (see external interrupts subsec­tion).
When an interrupt has to be serviced: – Normal processing is suspended at the end of
the current instruction execution.
– The PC, X, A and CC registersare saved onto
the stack.
– The I bit of the CC register is set to prevent addi-
tional interrupts.
– ThePC is thenloaded with theinterrupt vector of
the interrupt to service and the first instructionof the interrupt serviceroutine is fetched(refer to the Interrupt Mapping Table for vector address­es).
The interrupt service routine should finish with the IRET instruction which causes the contents of the saved registersto be recovered from thestack.
Note: As a consequence of the IRET instruction, the I bit will be cleared and the main program will resume.
Priority management
By default, a servicing interrupt can not be inter­rupted because the I bit is set by hardware enter­ing in interrupt routine.
In the case several interrupts are simultaneously pending, an hardware priority defines which one will be serviced first (seethe Interrupt Mapping Ta­ble).
Non Maskable Software Interrupts
This interrupt is entered when the TRAP instruc­tion is executed regardless of the state of theI bit. It will be serviced according to the flowchart on Figure 16.
Interrupts and Low power mode
All interrupts allowthe processorto leave the Wait low power mode. Only external and specific men­tioned interrupts allow the processor to leave the
Halt low power mode(referto the “Exit from HALT“ column in the Interrupt Mapping Table).
External Interrupts
External interrupt vectorscan be loaded in the PC register if the corresponding external interrupt oc­curred and if the I bit is cleared. These interrupts allow the processor to leave the Halt low power mode.
The external interrupt polarity is selected through the miscellaneous register or interrupt register (if available).
External interrupt triggered on edge will be latched and the interrupt request automatically cleared upon entering the interrupt service routine.
If several input pins, connected to the same inter­rupt vector, are configured as interrupts, their sig­nals are logically ANDed before entering theedge/ level detection block.
Warning: The type of sensitivity defined in the Miscellaneous or Interrupt register (if available) applies to the EI source. In case of an ANDed source (as described on the I/O ports section), a low level on an I/O pin configured as input with in­terrupt, masks the interrupt request even in case of rising-edge sensitivity.
Peripheral Interrupts
Different peripheral interrupt flags in the status register are able to cause an interrupt when they are active if both:
– TheI bit of the CC register is cleared. – Thecorresponding enablebit is set in thecontrol
register.
If any of these two conditions is false, theinterrupt is latched and thus remains pending.
Clearing an interrupt request is done by: – writing “0” to the corresponding bit in the status
register or
– anaccess to the status register while the flag is
set followed bya read or write of anassociated register.
Note: the clearing sequence resets the internal latch. A pending interrupt (i.e. waiting for being en­abled) will therefore be lost ifthe clear sequence is executed.
18/84
18
INTERRUPTS (Cont’d) Figure 16. Interrupt Processing Flowchart
FROM RESET
ST72101/ST72212/ST72213
EXECUTE INSTRUCTION
RESTORE PC, X, A,CC FROM STACK
BIT I SET
Y
FETCH NEXT INSTRUCTION
N
THIS CLEARS I BIT BY DEFAULT
IRET
Y
N
N
BIT I SET
Y
STACK PC, X, A, CC
SET I BIT
LOAD PC FROM INTERRUPT VECTOR
19/84
19
ST72101/ST72212/ST72213
Table 7. Interrupt Mapping
Source
Block
RESET Reset N/A N/A yes FFFEh-FFFFh
TRAP Software N/A N/A no FFFCh-FFFDh
EI0 External Interrupt PA0:PA7 N/A N/A yes FFFAh-FFFBh EI1 External Interrupt PB0:PB7, PC0:PC5 N/A N/A yes FFF8h-FFF9h
SPI
TIMER A
TIMER B
1)
Description
Not Used FFF6h-FFF7h
Transfer Complete
Mode Fault MODF
Input Capture 1
Output Compare 1 OCF1_A
Input Capture 2 ICF2_A
Output Compare 2 OCF2_A
Timer Overflow TOF_A
Not Used FFF0h-FFF1h
Input Capture 1
Output Compare 1 OCF1_B
Input Capture 2 ICF2_B
Output Compare 2 OCF2_B
Timer Overflow TOF_B
Not Used
Register
Label
SPISR
TASR
TBSR
Flag
SPIF
ICF1_A
ICF1_B
Exit
from
HALT
no FFF4h-FFF5h
no FFF2h-FFF3h
no FFEEh-FFEFh
Vector
Address
FFECh-FFEDh
FFEAh-FFEBh
FFE8h-FFE9h FFE6h-FFE7h FFE4h-FFE5h FFE2h-FFE3h
FFE0h-FFE1h
Priority
Order
Highest
Priority
Lowest Priority
Note 1: Timer B is available on ST72212 only.
20/84
20
3.4 POWER SAVING MODES
3.4.1 Introduction
There are threePower Saving modes. SlowMode is selected by setting the relevant bits in the Mis­cellaneous register. Wait and Halt modes may be entered usingthe WFI and HALT instructions.
ST72101/ST72212/ST72213
Figure 17. WAIT Flow Chart
WFI INSTRUCTION
3.4.2 Slow Mode
In Slow mode, the oscillator frequency can be di­vided by a value defined in the Miscellaneous Register. The CPU and peripherals are clocked at this lower frequency. Slow mode isused to reduce power consumption, andenables the user to adapt clock frequencyto available supply voltage.
3.4.3 Wait Mode
Wait mode places the MCU in a low power con­sumption mode by stoppingthe CPU. Allperipher­als remain active. During Wait mode, the I bit (CC Register) is cleared, so as to enable all interrupts. All otherregisters and memory remain unchanged. The MCU will remain in Wait mode until an Inter­rupt or Reset occurs, whereupon the Program Counter branches to the starting address of the In­terrupt orReset Service Routine. The MCU will remain in Wait mode until a Reset or an Interrupt occurs, causing it to wake up.
Refer to Figure 17 below.
N
INTERRUPT
Y
OSCILLATOR PERIPH. CLOCK CPU CLOCK
I-BIT
N
RESET
OSCILLATOR PERIPH. CLOCK CPU CLOCK
I-BIT
4096 CPU CLOCK
CYCLES DELAY
ON
ON
OFF CLEARED
Y
ON
ON
ON SET
OSCILLATOR PERIPH. CLOCK CPU CLOCK
I-BIT
FETCH RESET VECTOR
OR SERVICE INTERRUPT
Note: Before servicing an interrupt, the CC register is pushed on the stack. The I-Bit is set during the inter­rupt routine and cleared when the CC register is popped.
ON
ON
ON SET
21/84
21
ST72101/ST72212/ST72213
POWER SAVINGMODES (Cont’d)
3.4.4 Halt Mode
The Halt mode is the MCU lowest power con­sumption mode. The Halt mode is entered byexe­cuting theHALT instruction. The internal oscillator is then turnedoff, causing allinternal processing to be stopped, including the operation of the on-chip peripherals. The Halt mode cannot be used when the watchdog isenabled, ifthe HALT instruction is executed while the watchdog system is enabled,a watchdog reset is generatedthus resetting the en­tire MCU.
When entering Halt mode, the Ibit in the CC Reg­ister is clearedso as toenable ExternalInterrupts. If an interrupt occurs, the CPU becomes active.
The MCU canexit theHalt mode upon reception of an interrupt or a reset. Refer to the Interrupt Map­ping Table. The oscillator is then turned on and a stabilization time is provided beforereleasing CPU operation. Thestabilization timeis 4096 CPU clock cycles.
After the start up delay, the CPU continuesoper­ation byservicingthe interrupt whichwakes it up or by fetching the reset vector if a reset wakes it up.
Figure 18. HALT Flow Chart
HALT INSTRUCTION
WATCHDOG
RESET
N
EXTERNAL
INTERRUPT
Y
OSCILLATOR PERIPH. CLOCK CPU CLOCK I-BIT
N
1)
WDG
ENABLED?
N
OFF
OFF
OFF CLEARED
RESET
Y
Y
1) or some specific interrupts
2) if reset PERIPH. CLOCK = ON ;if interrupt PERIPH. CLOCK = OFF
Note: Before servicing an interrupt, the CC register is pushed on the stack. The I-Bit is set during the inter­rupt routine and cleared when the CC register is popped.
OSCILLATOR PERIPH. CLOCK CPU CLOCK I-BIT
4096 CPU CLOCK
CYCLES DELAY
OSCILLATOR PERIPH. CLOCK
CPU CLOCK I-BIT
FETCH RESET VECTOR
OR SERVICE INTERRUPT
ON
2)
OFF
ON SET
ON
ON
ON SET
22/84
22
3.5 MISCELLANEOUS REGISTER
ST72101/ST72212/ST72213
The Miscellaneous register allows to select the SLOW operatingmode, the polarity of external in­terrupt requestsand to output the internal clock.
Register Address:0020h — Read/Write Reset Value: 0000 0000 (00h)
70
PEI3 PEI2 MCO PEI1 PEI0 - - SMS
Bit 7:6 = PEI[3:2]
Option
.
External Interrupt EI1 Polarity
These bits are set and cleared by software. They
Bit 4:3 = PEI[1:0]
Option
.
External Interrupt EI0 Polarity
These bits are set and cleared by software. They determine which event on EI0 causes the exter­nal interrupt according to Table 9.
Table 9. EI0 External Interrupt Polarity Options
MODE PEI1 PEI0
Falling edge and low level
(Reset state)
Falling edge only 1 0
Rising edge only 0 1
Rising and falling edge 1 1
determine which event on EI1 causes the exter­nal interrupt according to Table 8.
Note: Any modification of oneof these two bits re-
Table 8. EI1 External Interrupt Polarity Options
MODE PEI3 PEI2
Falling edge and low level
(Reset state)
Falling edge only 1 0
Rising edge only 0 1
Rising and falling edge 1 1
00
Note: Any modification of one of these twobits re­sets the interrupt request related to this interrupt vector.
Bit 5 = MCO
Main Clock Out
sets the interrupt request related to this interrupt vector.
Bit 1:2 = Unused, always read at 0.
Warning:
Software must write 1 to these bits for
compatibility with future products.
Bit 0 = SMS
Slow Mode Select
This bit is set andcleared by software. 0- Normal mode - f
= Oscillator frequency / 2
CPU
(Reset state)
1- Slow mode - f
= Oscillatorfrequency /32
CPU
This bit isset andcleared by software. When set, it enables the output of the Internal Clock on the PC2 I/Oport. 0 -PC2 is a general purpose I/O port. 1 -MCO alternate function (f
is output on PC2
CPU
pin).
00
23/84
23
ST72101/ST72212/ST72213
4 ON-CHIP PERIPHERALS
4.1 I/O PORTS
4.1.1 Introduction
The I/O ports offer different functional modes: – transferof data through digital inputsand outputs and forspecific pins: – analog signal input (ADC) – alternate signal input/output for the on-chip pe-
ripherals. – external interrupt generation An I/O port is composed of up to 8 pins. Each pin
can be programmedindependently as digital input (with or without interrupt generation) or digital out­put.
4.1.2 Functional Description
Each portis associated to 2 main registers: – Data Register (DR) – Data Direction Register (DDR) and someof them to an optional register: – Option Register (OR) Each I/Opin may beprogrammed using thecorre-
sponding register bits inDDR and ORregisters: bit X corresponding to pin Xof the port.The same cor­respondence is used for the DR register.
The following description takes into account the OR register, for specific ports whichdo not provide this register refer to the I/O Port Implementation Section 4.1.3. The generic I/O block diagram is shown onFigure 20.
4.1.2.1 Input Modes
The input configuration isselected by clearing the corresponding DDRregister bit.
In this case, reading the DR register returns the digital value applied to the external I/O pin.
Different input modes can beselected by software through theOR register.
Notes:
1. All the inputs are triggered by a Schmitt trigger.
2. When switching from input mode to output mode, the DR register should be written first to output the correct value as soon as the port is con­figured as an output.
Interrupt function
When an I/O is configured in Input with Interrupt, an event on this I/O can generate an external In­terrupt request to the CPU. Theinterrupt polarity is given independently according to the description mentioned in the Miscellaneous register or in the interrupt register (where available).
Each pin can independently generate an Interrupt request.
Each external interrupt vector is linked to a dedi­cated group of I/O port pins (see Interrupts sec­tion). If several input pins are configured as inputs to the same interrupt vector, their signals are logi­cally ANDed before entering the edge/level detec­tion block. For this reason if one of the interrupt pins is tied low, it masks the other ones.
4.1.2.2 Output Mode
The pin is configured in output mode bysetting the corresponding DDR registerbit.
In this mode, writing “0” or “1” to the DR register applies this digital value to the I/O pin through the latch. Then reading the DR register returns the previously stored value.
Note: In this mode, the interrupt function is disa­bled.
4.1.2.3 Digital Alternate Function
When an on-chipperipheral is configured to use a pin, the alternate function is automatically select­ed. This alternate function takes priority over standard I/O programming. When the signal is coming from an on-chip peripheral, the I/O pin is automatically configuredin output mode (push-pull or open drain according to theperipheral).
When the signal is going to an on-chip peripheral, the I/O pin has to be configured ininput mode. In this case, the pin’s state is also digitally readable by addressing the DR register.
Notes:
1. Input pull-up configuration can cause an unex­pected value atthe input of the alternate peripher­al input.
2. When the on-chip peripheral uses apin asinput and output, this pin must be configured as an input (DDR = 0).
Warning
vated as long as the pin isconfigured as inputwith interrupt, in order to avoid generating spurious in­terrupts.
: The alternate function must not be acti-
24/84
24
I/O PORTS (Cont’d)
4.1.2.4 Analog Alternate Function
When the pin isused asan ADC input theI/O must be configured as input, floating. The analog multi­plexer (controlled by the ADC registers) switches the analog voltage present on the selected pin to the common analog rail which is connected to the ADC input.
It isrecommended 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.
Warning
: The analog input voltage level must be
4.1.3 I/O Port Implementation
The hardware implementation oneach I/O port de­pends on the settingsin theDDR andOR registers and specific feature ofthe I/O portsuch as ADCIn­put (see Figure 20) or true open drain. Switching these I/O ports from one state to another should be done in a sequence that prevents unwanted side effects. Recommended safetransitions areil­lustrated in Figure 19. Other transitions are poten­tially risky and should be avoided, since they are likely to present unwanted side-effects such as spurious interrupt generation.
within the limits stated in the Absolute Maximum Ratings.
Figure 19. Recommended I/O State Transition Diagram
ST72101/ST72212/ST72213
INPUT
with interrupt
INPUT
no interrupt
OUTPUT
OUTPUT push-pullopen-drain
25
25/84
ST72101/ST72212/ST72213
I/O PORTS (Cont’d) Figure 20. I/O BlockDiagram
ALTERNATE OUTPUT
ALTERNATE ENABLE
1
M U
X
0
V
DD
P-BUFFER
(S
EE TABLE BELOW)
DATA BUS
EE TABLE BELOW)
(S
COMMON ANALOG RAIL
DR SEL
ALTERNATE INPUT
DR
LATCH
DDR LATCH
OR
LATCH
ORSEL
DDR SEL
ALTERNATE ENABLE
PULL-UP CONDITION
PULL-UP
V
DD
DIODE
(SEE TABLEBELOW)
PAD
ANALOG ENABLE
(ADC)
ANALOG
GND
SWITCH
(S
EE NOTE BELOW)
N-BUFFER
ALTERNATE
1 M U
X
0
ENABLE
GND
CMOS
SCHMITT TRIGGER
EXTERNAL INTERRUPT
POLARITY
SEL
FROM OTHER BITS
SOURCE (EIx)
Table 10. Port Mode Configuration
Configuration Mode Pull-up P-buffer V
Floating 0 0 1 Pull-up 1 0 1 Push-pull 0 1 1
True Open Drain not present not present Open Drain (logic level) 0 0 1
Legend: 0 - present, not activated 1 - present and activated
Notes:
– No OR Register on some ports (see register map). – ADC Switch on ports with analog alternate functions.
26/84
DD
not present in OTP
and EPROM devices
26
Diode
Table 11. Port Configuration
ST72101/ST72212/ST72213
Port Pin Name
OR = 0 OR =1 OR = 0 OR = 1
Port A PA0:PA7 Floating* Floating with Interrupt Port B PB0:PB7 Floating* Pull-up with Interrupt Open Drain (Logic level) Push-pull
Port C PC0:PC5 Floating* Pull-up with Interrupt Open Drain (Logic level) Push-pull
Input (DDR = 0) Output (DDR = 1)
True Open Drain,
High Sink Capability
Reserved
*Reset State
27
27/84
ST72101/ST72212/ST72213
I/O PORTS (Cont’d)
4.1.4 Register Description
4.1.4.1 Data registers
Port A Data Register (PADR) Port B Data Register (PBDR) Port C Data Register (PCDR) Read/Write
Reset Value: 0000 0000 (00h)
4.1.4.3 Option registers
Port A OptionRegister (PAOR) Port B OptionRegister (PBOR) Port C Option Register (PCOR) Read/Write
Reset Value: 0000 0000 (00h) (nointerrupt)
70
D7 D6 D5 D4 D3 D2 D1 D0
Bit 7:0 = D7-D0
Data Register 8 bits.
The DR register has a specific behaviour accord­ing to the selected input/output configuration. Writ­ing the DR register is always taken in account even if the pin is configured as an input. Reading the DR register returns either theDR register latch content (pin configuredas output) or the digital val­ue applied to the I/O pin (pin configured as input).
4.1.4.2 Data direction registers
Port A Data Direction Register (PADDR) Port B Data Direction Register (PBDDR) Port C Data Direction Register (PCDDR) Read/Write
Reset Value: 0000 0000 (00h) (input mode)
70
DD7 DD6 DD5 DD4 DD3 DD2 DD1 DD0
70
O7 O6 O5 O4 O3 O2 O1 O0
Bit 7:0 = O7-O0
Option Register8 bits.
For specific I/O pins, thisregister is not implement­ed. In this case the DDR register is enough to se­lect the I/O pin configuration.
The OR register allow to distinguish: in input mode if the interrupt capability or the floating configura­tion is selected, in output mode if the push-pull or open drain configuration is selected.
Each bit is set and clearedby software. Input mode: 0: floating input
1: input interrupt with or without pull-up Output mode (only for PB0:PB7, PC0:PC5): 0: output open drain (with P-Bufferinactivated)
1: output push-pull Output mode (only for PA0:PA7): 0: output open drain 1: reserved
Bit 7:0 = DD7-DD0
Data Direction Register 8 bits.
The DDR register gives the input/output direction configuration of the pins. Each bit is set and cleared by software.
0: Input mode 1: Output mode
28/84
28
I/O PORTS (Cont’d) Table 12. I/O Port RegisterMap and Reset Values
ST72101/ST72212/ST72213
Address
(Hex.)
0000h
0001h
0002h
0004h
0005h
0006h
0008h
0009h
000Ah
Register
Label
PCDR
Reset Value
PCDDR
Reset Value
PCOR
Reset Value
PBDR
Reset Value
PBDDR
Reset Value
PBOR
Reset Value
PADR
Reset Value
PADDR
Reset Value
PAOR
Reset Value
76543210
D7
0
DD7
0
O7
0
D7
0
DD7
0
O7
0
D7
0
DD7
0
O7
0
D6
0
DD6
0
O6
0
D6
0
DD6
0
O6
0
D6
0
DD6
0
O6
0
D5
0
DD5
0
O5
0
D5
0
DD5
0
O5
0
D5
0
DD5
0
O5
0
D4
0
DD4
0
O4
0
D4
0
DD4
0
O4
0
D4
0
DD4
0
O4
0
D37
0
DD3
0
O3
0
D37
0
DD3
0
O3
0
D37
0
DD3
0
O3
0
D2
0
DD2
0
O2
0
D2
0
DD2
0
O2
0
D2
0
DD2
0
O2
0
D1
0
DD1
0
O1
0
D1
0
DD1
0
O1
0
D1
0
DD1
0
O1
0
D0
0
DD0
0
O0
0
D0
0
DD0
0
O0
0
D0
0
DD0
0
O0
0
29
29/84
ST72101/ST72212/ST72213
4.2 WATCHDOG TIMER (WDG)
4.2.1 Introduction
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 theprogram refresh­es the counter’s contents before the T6 bit be­comes cleared.
Figure 21. Watchdog Block Diagram
RESET
WATCHDOG CONTROL REGISTER (CR)
T5
WDGA
T6 T0
T4
7-BIT DOWNCOUNTER
4.2.2 Main Features
Programmable timer (64 increments of 12288
CPU cycles)
Programmablereset
Reset (if watchdog activated) after a HALT
instruction or whenthe T6 bit reaches zero
T1
T2
T3
30/84
30
f
CPU
CLOCK DIVIDER
÷12288
WATCHDOG TIMER (Cont’d)
4.2.3 Functional Description
The counter value stored in the CR register (bits T6:T0), is decremented every 12,288 machine cy­cles, and the length of the timeout period can be programmed by the user in 64increments.
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 becomes cleared), it initiates a reset cycle pulling low the reset pin for typically 500ns.
The application program must write in theCR 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 13):
– The WDGA bit is set (watchdog enabled) – The T6 bit is set to prevent generating an imme-
diate reset
– TheT5:T0 bits containthenumber ofincrements
which represents the time delay before the watchdog produces areset.
Table 13. Watchdog Timing (f
CR Register
initial value
Max FFh 98.304
Min C0h 1.536
= 8MHz)
CPU
WDG timeout period
(ms)
Notes: Following a reset, the watchdog is disa-
bled. Onceactivated it cannot be disabled, except by areset.
The T6 bit can be used to generate a software re­set (the WDGA bitis set and the T6 bit is cleared).
If the watchdog is activated, the HALT instruction will generate a Reset.
ST72101/ST72212/ST72213
4.2.4 Low Power Modes Mode Description
WAIT No effect on Watchdog.
Immediate reset generation assoon as
HALT
4.2.5 Interrupts
None.
4.2.6 Register Description
CONTROL REGISTER (CR)
Read/Write Reset Value: 0111 1111 (7Fh)
70
WDGA T6 T5 T4 T3 T2 T1 T0
Bit 7 = WDGA This bit is set by software and only cleared by hardware after a reset. When WDGA = 1, the watchdog can generatea reset. 0: Watchdog disabled 1: Watchdog enabled
Bit 6:0 = T[6:0] These bits contain the decremented value. A reset is produced when it rolls overfrom 40h to 3Fh(T6 becomes cleared).
the HALT instruction is executed ifthe Watchdog is activated(WDGA bit is set).
Activation bit
.
7-bit timer (MSB to LSB).
Table 14. Watchdog Timer Register Map and Reset Values
Address
(Hex.)
0024h
Register
Label
WDGCR
Reset Value
76543210
WDGA
0
T6
T5
1
1
T4
1
T3
T2
1
1
T1
T0
1
1
31/84
31
ST72101/ST72212/ST72213
4.3 16-BIT TIMER
4.3.1 Introduction
The timer consists of a 16-bit free-running counter driven by a programmable prescaler.
It may be used for a variety of purposes, including pulse length measurement of up to two input sig­nals (
input capture
put waveforms ( 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.
4.3.2 Main Features
Programmableprescaler:f
Overflow statusflag and maskable interrupt
External clock input (must be at least 4 times
slower thantheCPUclockspeed)withthe choice of activeedge
Output compare functions with
– 2 dedicated 16-bitregisters – 2 dedicated programmablesignals – 2 dedicated statusflags – 1 dedicated maskableinterrupt
Input capturefunctions with
– 2 dedicated 16-bitregisters – 2 dedicated active edge selection signals – 2 dedicated statusflags – 1 dedicated maskableinterrupt
Pulse widthmodulation mode (PWM)
One pulse mode
5 alternatefunctionson I/Oports (ICAP1,ICAP2,
OCMP1, OCMP2, EXTCLK)*
) orgeneration of upto two out-
output compare
and
PWM
dividedby2,4or8.
CPU
).
4.3.3 Functional Description
4.3.3.1 Counter
The principal block of the Programmable Timer is a 16-bit free running increasing counter and itsas­sociated 16-bit registers:
Counter Registers
– Counter High Register (CHR) isthe most sig-
nificant byte (MSB).
– Counter Low Register (CLR) is the least sig-
nificant byte (LSB).
Alternate Counter Registers
– AlternateCounter HighRegister (ACHR) is the
most significant byte(MSB).
– AlternateCounter Low Register (ACLR) is the
least significant byte (LSB).
These two read-only 16-bit registers contain the same value but with the differencethat reading the ACLR register doesnot clear the TOF bit (overflow flag), (see note at the end of paragraph titled16-bit read sequence).
Writing in the CLRregister or ACLR register resets the free running counter to the FFFCh value.
The timer clock depends on the clock control bits of the CR2 register, as illustratedin Table 15. The value in the counter register repeats every
131.072, 262.144 or 524.288 internal processor-
clock cycles depending on the CC1and CC0 bits.
The Block Diagram is shown in Figure 22. *Note: Some external pins are not available on all
devices. Refer to the devicepin outdescription. When reading an input signal which is not availa-
ble on an external pin, the value will always be ‘1’.
32/84
32
16-BIT TIMER (Cont’d) Figure 22. Timer Block Diagram
f
CPU
ST72101/ST72212/ST72213
ST7 INTERNAL BUS
MCU-PERIPHERAL INTERFACE
CC1 CC0
EXTCLK
EXEDG
1/2 1/4
1/8
8 high
FREE RUNNING
ALTERNATE REGISTER
OVERFLOW
8 low
8-bit
buffer
16 BIT
COUNTER
COUNTER
DETECT
CIRCUIT
high
16
OUTPUT
COMPARE
REGISTER
16
OUTPUT COMPARE
8
low
1
high
OUTPUT
COMPARE REGISTER
2
TIMER INTERNAL BUS
16 16
CIRCUIT
6
888
low
8
low
high
INPUT
CAPTURE
REGISTER
1
EDGE DETECT
EDGE DETECT
888
high
low
INPUT
CAPTURE
REGISTER
2
16
CIRCUIT1
CIRCUIT2
16
ICAP1
ICAP2
TIMER INTERRUPT
LATCH1
ICF2ICF1 000OCF2OCF1 TOF
SR
CR1
OC2E
OPMFOLV2ICIE OLVL1IEDG1OLVL2FOLV1OCIE TOIE
PWMOC1E EXEDGIEDG2CC0CC1
LATCH2
CR2
OCMP1
OCMP2
33/84
33
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d) 16-bit read sequence: (from either the Counter
Register orthe Alternate Counter Register).
Beginning of the sequence
At t0
Read MSB
Other
instructions
At t0 +t
Read LSB
Sequence completed
The user must read the MSB first, then the LSB value isbuffered automatically.
This buffered value remains unchanged until the 16-bit read sequence is completed, even if the user readsthe MSB several times.
After a complete reading sequence, if only the CLR register or ACLR register are read, they re­turn the LSB of the count value at the time of the read.
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 to0000h then:
– The TOF bitof the SRregister is set. – A timer interrupt is generated if:
– TOIE bit of the CR1 registeris set and – I bit ofthe 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.
LSB is buffered
Returns the buffered
LSB value at t0
Clearing the overflow interrupt request is done in two steps:
1.Reading theSR registerwhile the TOF bit isset.
2.An access (read or write) to the CLR register.
Notes: The TOF bit is not cleared by accesses to ACLR register. This feature allows simultaneous use of the overflow function and reads of the free running counter at random times (for example, to measure elapsed time) without the risk ofclearing the TOF biterroneously.
The timer is not affected byWAIT mode. In HALT mode,the counter stops countinguntil the
mode is exited. Counting then resumes from the previous count(MCU awakenedby an interrupt) or from the reset count (MCU awakened by aReset).
4.3.3.2 External Clock
The external clock (where available) is selected if CC0=1 and CC1=1 in CR2 register.
The status of the EXEDG bit determines the type of level transition on the external clock pin EXT­CLK that willtrigger the free running counter.
The counter is synchronised with the falling edge of the internal CPU clock.
At least four falling edges of the CPU clock must occur between two consecutive active edges of the external clock; thus the external clock frequen­cy must be less than a quarter of the CPU clock frequency.
34/84
34
16-BIT TIMER (Cont’d) Figure 23. Counter Timing Diagram, internal clock dividedby 2
CPU CLOCK
INTERNAL RESET
TIMER CLOCK
ST72101/ST72212/ST72213
COUNTER REGISTER
OVERFLOW FLAG TOF
FFFD FFFE FFFF 0000 0001 0002 0003
Figure 24. Counter Timing Diagram, internal clock dividedby 4
CPU CLOCK
INTERNAL RESET
TIMERCLOCK
COUNTER REGISTER
OVERFLOW FLAG TOF
FFFC FFFD 0000 0001
Figure 25. Counter Timing Diagram, internal clock dividedby 8
CPU CLOCK
INTERNAL RESET
TIMER CLOCK
COUNTER REGISTER
OVERFLOW FLAG TOF
FFFC FFFD
0000
35/84
35
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d)
4.3.3.3 Input Capture
In this section, the index,i, may be 1 or 2. 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 detected by the ICAPipin (see figure 5).
MS Byte LS Byte
ICiR IC
ICiregister is a read-only register. The active transition is software programmable
through theIEDGibitof theControl Register(CRi). Timing resolution is one count of the free running
counter: (f
/(CC1.CC0)).
CPU
Procedure:
To use the input capturefunction select thefollow­ing in the CR2 register:
– Select the timer clock (CC1-CC0) (see Table
15).
– Select the edge of the active transition on the
ICAP2 pin with the IEDG2 bit (the ICAP2 pin
must be configured as floating input). And selectthe following in theCR1 register: – Set the ICIE bit to generate an interruptafter an
input capture coming from both the ICAP1 pin or
the ICAP2 pin – Select the edge of the active transition on the
ICAP1 pin with theIEDG1 bit(the ICAP1pinmust
be configured as floating input).
i
HR ICiLR
When an input capture occurs: – ICFibit is set. – The ICiR register contains the value of the free
running counter on the active transition on the ICAPipin (seeFigure 27).
– Atimer interrupt is generatedif the ICIEbit is set
and theI bit is cleared in the CC register.Other­wise, the interrupt remains pending until both conditions become true.
Clearing the Input Capture interrupt request is done in two steps:
1.Reading the SRregister while the ICFibitis set.
2.An access (read or write) to the ICiLR register.
Notes:
1.After reading the ICiHR register, transfer of input capture data is inhibited until the ICiLR register is also read.
2.The ICiR register always contains the free run­ning counter value which corresponds to the most recentinput capture.
3.The 2 input capture functions can be used together even if the timer also uses the output compare mode.
4.In One pulse Mode and PWM mode only the input capture 2 can be used.
5.The alternate inputs (ICAP1 & ICAP2) are always directly connected to the timer. So any transitions on these pins activate the input cap­ture process.
6.Moreover if one of the ICAPipin is configured as an input and the second one as an output, an interrupt can be generated if the user toggle the output pin and if the ICIE bit isset.
7.The TOF bit can be used with interrupt in order to measure event that go beyond the timer range (FFFFh).
36/84
36
16-BIT TIMER (Cont’d) Figure 26. Input Capture Block Diagram
ST72101/ST72212/ST72213
ICAP1
pin
ICAP2
pin
EDGE DETECT
CIRCUIT2
16-BIT
EDGE DETECT
CIRCUIT1
IC1R RegisterIC2R Register
16-BIT FREE RUNNING
COUNTER
Figure 27. Input Capture Timing Diagram
TIMER CLOCK
ICIE
(Control Register 1) CR1
IEDG1
(Status Register) SR
ICF2ICF1 000
(Control Register 2) CR2
IEDG2
CC0
CC1
COUNTER REGISTER
ICAPi PIN
ICAPi FLAG
ICAPi REGISTER
Note: A
ctive edge is rising edge.
FF01 FF02 FF03
FF03
37/84
37
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d)
4.3.3.4 Output Compare
In this section, the index,i, may be 1 or 2. This function can be used to control an output
waveform or indicating when a period of time has elapsed.
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
OCIE bit is set – Sets a flag in the status register – Generates an interrupt if enabled
Two 16-bit registers Output Compare Register 1 (OC1R) and Output Compare Register 2 (OC2R) contain the value to be compared to the free run­ning counter each timer clock cycle.
MS Byte LS Byte
OC
i
ROC
These registers are readable and writable and are not affected by the timer hardware. A reset event changes the OCiR valueto 8000h.
Timing resolution is one count of the free running counter: (f
CPU/(CC1.CC0)
Procedure:
To use the outputcompare function, select thefol­lowing in the CR2 register:
– Set the OCiE bit if an output is needed then the
OCMPipin is dedicated to the output compare function.
– Select the timer clock (CC1-CC0) (see Table
15). And selectthe following in theCR1 register: – Select theOLVLibitto applied to theOCMPipins
after the matchoccurs.
– Set the OCIE bit to generate an interrupt if it is
needed. When a match is found: – OCFibit is set. – The OCMPipin takes OLVLibit value (OCMP
pin latch is forced low during reset andstays low
until valid compares change it to a high level). – A timer interrupt is generated if the OCIE bit is
set in the CR2 register and the I bit iscleared in
the CC register (CC). The OCiR register valuerequired for a specifictim-
ing application can be calculated using thefollow­ing formula:
i
HR OCiLR
).
i
t*f
OC
i
R=
CPU
PRESC
Where:
t = Desired output compare period (in sec-
onds)
f
CPU
PRESC
Clearing the output compare interrupt request is done by:
1.Reading the SR register while the OCFibit is
2.An access (read or write) to the OCiLR register. The following procedure is recommended to pre-
vent the OCFibit from being set between the time it is read and the write to the OCiR register:
– Writeto the OCiHR register (further compares
– Readthe SR register (firststep of theclearance
– Writeto the OCiLR register (enablesthe output
Notes:
1.After a processor write cycle to the OCiHR reg-
i
2.If the OCiE bit is not set, the OCMPipin is a
3.When the clock is divided by 2, OCFiand
4.The output compare functions can be usedboth
5.The value in the 16-bit OCiR register and the
= Internal clock frequency = Timer prescaler factor (2, 4 or 8 de-
pending on CC1-CC0 bits, see Table
15)
set.
are inhibited).
of the OCFibit, which may be already set).
compare functionand clears the OCFibit).
ister, the output compare function is inhibited until theOCiLR register is also written.
general I/O port and the OLVLibit will not appear when a match is found but an interrupt could be generated if the OCIE bit is set.
OCMPiare set while the counter value equals the OCiR register value (see Figure 29, on page 39). This behaviour is the same in OPM or PWM mode. When the clock is divided by 4, 8 or in external clock mode, OCFiand OCMPiare set while the counter value equals the OCiR register value plus 1(see Figure 30, on page39).
for generating external events on the OCMP pins even if the input capture mode is also used.
OLVibit should be changed after each suc­cessful comparisonin orderto control an output waveform orestablish a new elapsed timeout.
i
38/84
38
16-BIT TIMER (Cont’d) Figure 28. Output Compare BlockDiagram
ST72101/ST72212/ST72213
16 BIT FREE RUNNING
COUNTER
16-bit
OUTPUT COMPARE
CIRCUIT
16-bit
OC1R Register
16-bit
OC2R Register
OC1E CC0CC1
OC2E
(Control Register 2) CR2
(Control Register 1) CR1
OLVL1OLVL2OCIE
000OCF2OCF1
(Status Register) SR
Figure 29. Output Compare Timing Diagram, Internal Clock Divided by 2
INTERNAL CPU CLOCK
TIMER CLOCK
COUNTER
OUTPUT COMPARE REGISTER
2ED0 2ED1 2ED2
2ED3
2ED3
Latch
1
Latch
2
2ED42ECF
OCMP1
Pin
OCMP2
Pin
OUTPUT COMPARE FLAG (OCFi)
OCMPi PIN (OLVLi=1)
Figure 30. Output Compare Timing Diagram, Internal Clock Divided by 4
INTERNAL CPU CLOCK
TIMER CLOCK
COUNTER
OUTPUT COMPARE REGISTER
COMPARE REGISTER LATCH
OCFi AND OCMPi PIN (OLVLi=1)
2ED0 2ED1 2ED2
2ED3
2ED3
2ED42ECF
39/84
39
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d)
4.3.3.5 Forced Compare
In this sectionimay represent 1 or 2. The following bits of the CR1 register are used:
FOLV2 FOLV1 OLVL2 OLVL1
When the FOLVibit is set by software, the OLVL bit iscopied to the OCMPipin. The OLVibithas to be toggled in order to toggle the OCMPipin when it is enabled (OCiE bit=1). The OCFibitis then not set by hardware, and thus no interrupt request is generated.
FOLVLibitshaveno effectin both one pulse mode and PWMmode.
4.3.3.6 One Pulse Mode
One Pulse mode enables the generation of a pulse when an externalevent occurs.This mode is selected viathe OPM bit inthe CR2 register.
The one pulse mode uses the Input Capture1 function and the Output Compare1 function.
Procedure:
To useone pulse mode:
1. Load the OC1R register with the value corre-
sponding to the length of the pulse (see thefor­mula inSection 4.3.3.7).
2. Select the following in the CR1 register:
– Using the OLVL1 bit, select the levelto be ap-
plied to the OCMP1 pin after the pulse.
– Using the OLVL2 bit, select the levelto be ap-
plied to the OCMP1 pin during the pulse.
– Select the edge of the active transition on the
ICAP1 pin with the IEDG1 bit (the ICAP1 pin must be configured as floating input).
3. Select the following in the CR2 register:
– Set the OC1E bit, the OCMP1 pin is then ded-
icated to the Output Compare 1 function. – Set the OPM bit. – Select the timer clock CC1-CC0 (see Table
15).
One pulsemode cycle
When
event occurs
on ICAP1
OCMP1 = OLVL2
Counter is reset
to FFFCh
i
ICF1 bit is set
When
Counter = OC1R
OCMP1 = OLVL1
Then, on a valid event on the ICAP1 pin, the coun­ter is initialized to FFFCh and OLVL2 bit is loaded on the OCMP1pin, the ICF1 bit is set and theval­ue FFFDh is loaded in the IC1R register.
When the value of the counteris equal to the value of the contents of the OC1R register, the OLVL1 bit is output on the OCMP1pin, (See Figure 31).
Notes:
1.The OCF1 bit cannot be set by hardware in one pulse mode but the OCF2 bit can generate an Output Compareinterrupt.
2.The ICF1 bit is set when an active edge occurs and can generate an interrupt if the ICIE bit is set.
3.When the Pulse Width Modulation (PWM) and One Pulse Mode (OPM) bits are both set, the PWM modeis the only active one.
4.If OLVL1=OLVL2 a continuous signal will be seen onthe OCMP1 pin.
5.The ICAP1 pin cannot be usedto perform input capture. TheICAP2 pin can be used to perform input capture(ICF2 canbe set andIC2R 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.
6.When the one pulse mode is used OC1R is dedicated to this mode. Nevertheless OC2R and OCF2 can be used to indicate a period of time has been elapsed but cannot generate an output waveform because the level OLVL2 is dedicated to the one pulse mode.
40/84
40
Figure 31. One Pulse Mode Timing Example
....
COUNTER
ICAP1
FFFC FFFD FFFE 2ED0 2ED1 2ED2
ST72101/ST72212/ST72213
FFFC FFFD
2ED3
OCMP1
OLVL2
compare1
Note: IEDG1=1, OC1R=2ED0h, OLVL1=0, OLVL2=1
Figure 32. Pulse Width Modulation Mode Timing Example
COUNTER
OCMP1
34E2 FFFC FFFD FFFE 2ED0 2ED1 2ED2 34E2 FFFC
OLVL2
compare2 compare1 compare2
Note: OC1R=2ED0h, OC2R=34E2, OLVL1=0, OLVL2= 1
OLVL2OLVL1
OLVL2OLVL1
41
41/84
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d)
4.3.3.7 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 pulse width modulation mode uses the com­plete Output Compare 1 function plus the OC2R register, and so these functionality can not be used whenthe PWM mode is activated.
Procedure
To usepulse width modulation mode:
1. Load the OC2R register with the value corre­sponding to the period of the signal.
2. Load the OC1R register with the value corre­sponding to the length of the pulse if (OLVL1=0 and OLVL2=1).
3. Select the following in the CR1 register: – Using the OLVL1 bit, select the levelto be ap-
plied to the OCMP1 pin after a successful comparison with OC1R register.
– Using the OLVL2 bit, select the levelto be ap-
plied to the OCMP1 pin after a successful comparison with OC2R register.
4. Select the following in the CR2 register: – Set OC1E bit: the OCMP1 pinis thendedicat-
ed to the output compare 1 function. – Set the PWM bit. – Select the timer clock (CC1-CC0) (see Table
15).
If OLVL1=1 and OLVL2=0 the length of the posi­tive pulse is the difference betweenthe OC2R and OC1R registers.
If OLVL1=OLVL2 a continuous signal will be seen on the OCMP1 pin.
The OCiR register valuerequired for a specifictim­ing application can be calculated using thefollow­ing formula:
t*f
OCiR Value=
CPU
PRESC
Where: t = Desired output compare period (in sec-
onds)
f
CPU
PRESC
= Internal clock frequency = Timer prescaler factor (2, 4 or 8 de-
pending on CC1-CC0 bits, see Table
15)
-5
The Output Compare 2 event causes the counter to be initializedto FFFCh (SeeFigure 32).
Pulse Width Modulation cycle
When
Counter
OCMP1 = OLVL1
= OC1R
When
Counter = OC2R
OCMP1 = OLVL2
Counter is reset
to FFFCh
ICF1 bitis set
Notes:
1.After a write instruction to the OCiHR register, the output compare function is inhibited until the OCiLR register is also written. Therefore the Input Capture 1 function is inhib­ited but the Input Capture2 is available.
2.The OCF1 and OCF2 bits cannot be set by hardware in PWM mode therefore the Output Compare interruptis inhibited.
3.The ICF1 bit is set by hardware when the coun­ter reaches the OC2R value and can produce a timer interrupt if theICIE bit is setand the I bit is cleared.
4.In PWM mode the ICAP1 pin can not be used to perform input capture because it is discon­nected tothe timer.The ICAP2 pin can beused 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 period and ICF1 canalso generates interrupt if ICIE is set.
5.When the Pulse Width Modulation (PWM) and One Pulse Mode (OPM) bits are both set, the PWM modeis the only active one.
42/84
42
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d)
4.3.4 LowPower Modes
Mode Description
WAIT
HALT
4.3.5 Interrupts
Input Capture 1 event/Counter reset in PWM mode ICF1 Input Capture 2 event ICF2 Yes No Output Compare 1 event (not available in PWM mode) OCF1 Output Compare 2 event (not available in PWM mode) OCF2 Yes No Timer Overflow event TOF TOIE Yes No
No effect on 16-bit Timer. 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 whenthe MCU is woken up by an interrupt with “exit from HALT mode” capability or fromthe counter reset value when the MCU is woken up by a RESET.
i
If an input capture event occurs on the ICAP ly, when the MCU is woken up by an interrupt with“exit from HALT mode” capability, the ICF the counter value present when exiting from HALT mode is captured into the IC
Interrupt Event
pin, the input capture detection circuitry is armed. Consequent-
i
bit is set, and
i
R register.
Event
Flag
Enable
Control
Bit
ICIE
OCIE
Exit from Wait
Yes No
Yes No
Exit
from
Halt
Note: The 16-bit Timer interrupt events are con-
nected tothe sameinterrupt vector(see Interrupts chapter). These events generate an interrupt if the corre­sponding Enable Control Bit is set and the I-bit in the CC register is reset (RIM instruction).
43
43/84
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d)
4.3.6 Register Description
Each Timer is associated with three control and status registers, and with six pairsof data registers (16-bit values) relating to the two input captures, the two output compares, the counter and the al­ternate counter.
Bit 4 = FOLV2
Forced Output Compare 2.
This bit is set andcleared by software. 0: No effecton 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 isno successful comparison.
CONTROL REGISTER 1 (CR1)
Read/Write Reset Value: 0000 0000 (00h)
70
ICIE OCIE TOIE FOLV2 FOLV1 OLVL2 IEDG1 OLVL1
Bit 3 = FOLV1 This bit is set andcleared by software. 0: No effecton the OCMP1 pin. 1: Forces OLVL1 to becopied to theOCMP1 pin,if
the OC1E bit is set and even if there is no suc­cessful comparison.
Bit 2 = OLVL2
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 isset.
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 is copied to the OCMP2 pin whenever a successful comparison occurs withthe OC2Rreg­ister and OCxE is set in the CR2 register.This val­ue is copied to the OCMP1 pinin One Pulse Mode and Pulse Width Modulation mode.
Bit 1 = IEDG1 This bit determines which type of level transition on the ICAP1 pin will trigger the capture. 0: A falling edge triggers the capture.
Forced Output Compare 1.
Output Level 2.
Input Edge1.
1: A rising edge triggers the capture.
Bit 5 = TOIE 0: Interrupt is inhibited. 1: A timer interrupt is enabled whenever the TOF
bit of the SR register is set.
Timer Overflow Interrupt Enable.
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.
44/84
44
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d) CONTROL REGISTER 2 (CR2)
Read/Write Reset Value: 0000 0000 (00h)
70
OC1E OC2E OPM PWM CC1 CC0 IEDG2 EXEDG
Bit 4 = PWM
Pulse WidthModulation.
0: PWM modeis 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 valueof OC2R regis­ter.
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). Whateverthe value of theOC1E bit, the Output Compare1 function of the timer re­mains active. 0: OCMP1 pin alternate function disabled (I/O pin
free for general-purpose I/O).
1: OCMP1 pin alternate function enabled.
Bit 6 = OC2E
Output Compare 2 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 Output Compare 2 function of the timer re­mains active. 0: OCMP2 pin alternate function disabled (I/O pin
free for general-purpose I/O).
1: OCMP2 pin alternate function enabled.
Bit 5 = OPM
One PulseMode.
0: One Pulse Mode is not active. 1: One PulseMode isactive, theICAP1 pin can be
used totrigger one pulseon 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 3, 2 = CC1-CC0
Clock Control.
The value ofthe timer clock depends onthese bits:
Table 15. Clock Control Bits
Timer Clock CC1 CC0
f
/4 0 0
CPU
f
/2 0 1
CPU
f
/8 1 0
CPU
External Clock (where
available)
Bit 1 = IEDG2
Input Edge2.
11
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 0 = EXEDG
External Clock Edge.
This bit determines which type of level transition on the external clock pin EXTCLK will trigger the free running counter. 0: A falling edge triggers the freerunning counter. 1: A rising edge triggers the free running counter.
45
45/84
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d) STATUS REGISTER (SR)
Read Only Reset Value: 0000 0000 (00h) The three least significant bits arenot used.
70
ICF1 OCF1 TOF ICF2 OCF2 0 0 0
Bit 7 = ICF1
Input Capture Flag 1.
0: No input capture (reset value). 1: An input capture has occurred or the counter
has reached the OC2R value in PWM mode. To clear thisbit, firstread the SRregister, then read or write the low byte of the IC1R (IC1LR) regis­ter.
Bit 6 = OCF1
Output Compare Flag 1.
0: No match (reset value). 1: The content of the free running counter has
matched the content of the OC1R register. To clear thisbit, firstread the SRregister, then read or writethe low byte of the OC1R (OC1LR) reg­ister.
Bit 2-0 = Reserved, forced by hardware to 0.
INPUT CAPTURE 1 HIGH REGISTER (IC1HR)
Read Only Reset Value: Undefined
This is an8-bit read only register thatcontains the high part of the counter value (transferred by the input capture 1 event).
70
MSB LSB
INPUT CAPTURE 1 LOW REGISTER (IC1LR)
Read Only Reset Value: Undefined
This is an8-bit read only register thatcontains the low part of the counter value (transferred by the in­put capture 1 event).
70
MSB LSB
Bit 5 = TOF
Timer Overflow.
0: No timer overflow (reset value). 1:The freerunning counter rolled overfrom FFFFh
to 0000h. To clear thisbit, first read the SR reg­ister, then read or write the low byte of the CR (CLR) register.
Note: Reading or writing the ACLR register does not clear TOF.
Bit 4 = ICF2
Input Capture Flag 2.
0: No input capture (reset value). 1: An input capture has occurred.To clear this bit,
first read the SR register, then read or write the low byte of the IC2R (IC2LR) register.
Bit 3 = OCF2
Output Compare Flag 2.
0: No match (reset value). 1: The content of the free running counter has
matched the content of the OC2R register. To clear thisbit, firstread the SRregister, then read or writethe low byte of the OC2R (OC2LR) reg­ister.
OUTPUT COMPARE 1 HIGH REGISTER (OC1HR)
Read/Write Reset Value: 1000 0000 (80h)
This is an 8-bit register that contains the high part of the value to be comparedto the CHR register.
70
MSB LSB
OUTPUT COMPARE 1 LOW REGISTER (OC1LR)
Read/Write Reset Value: 0000 0000 (00h)
This isan 8-bitregister that containsthelow part of the value to be compared to the CLR register.
70
MSB LSB
46/84
46
16-BIT TIMER (Cont’d) OUTPUT COMPARE 2 HIGH REGISTER
(OC2HR)
Read/Write Reset Value: 1000 0000 (80h)
This is an 8-bit register that contains the high part of the value to be comparedto the CHRregister.
ST72101/ST72212/ST72213
ALTERNATE COUNTER HIGH REGISTER (ACHR)
Read Only Reset Value: 1111 1111 (FFh)
This is an 8-bit register that contains the high part of the counter value.
70
MSB LSB
OUTPUT COMPARE 2 LOW REGISTER (OC2LR)
Read/Write Reset Value: 0000 0000 (00h)
This is an 8-bitregister that contains thelow part of the value to be compared tothe CLR register.
70
70
MSB LSB
ALTERNATE COUNTER LOW REGISTER (ACLR)
Read Only Reset Value: 1111 1100 (FCh)
This isan 8-bitregister that containsthelow part of the counter value. Awrite to this register resets the counter. An access to this register after anaccess to SR register does not clear the TOF bit in SR register.
MSB LSB
COUNTER HIGH REGISTER (CHR)
70
MSB LSB
Read Only Reset Value: 1111 1111 (FFh)
This is an 8-bit register that contains the high part of the counter value.
70
INPUT CAPTURE 2 HIGH REGISTER (IC2HR)
Read Only Reset Value: Undefined
This is an8-bit read only register thatcontains the high part of the counter value (transferred by the
MSB LSB
Input Capture 2 event).
70
COUNTER LOW REGISTER (CLR)
MSB LSB
Read Only Reset Value: 1111 1100 (FCh)
This is an 8-bitregister that contains thelow part of the counter value. A writeto thisregisterresets the counter. Anaccess to this registerafter accessing the SR register clears the TOF bit.
70
INPUT CAPTURE 2 LOW REGISTER (IC2LR)
Read Only Reset Value: Undefined
This is an8-bit read only register thatcontains the low part of thecounter value(transferred by the In­put Capture 2 event).
MSB LSB
70
MSB LSB
47/84
47
ST72101/ST72212/ST72213
16-BIT TIMER (Cont’d) Table 16. 16-Bit Timer Register Map and Reset Values
Address
(Hex.)
TimerA: 32 TimerB: 42 TimerA: 31 TimerB: 41 TimerA: 33 TimerB: 43SRReset Value TimerA: 34 TimerB: 44
TimerA: 35 TimerB: 45
TimerA: 36 TimerB: 46 TimerA: 37 TimerB: 47 TimerA: 3E TimerB: 4E TimerA: 3F TimerB: 4F
TimerA: 38 TimerB: 48 TimerA: 39 TimerB: 49 TimerA: 3A TimerB: 4A TimerA: 3B TimerB: 4B
TimerA: 3C TimerB: 4C TimerA: 3D TimerB: 4D
Register
Name
CR1
Reset Value
CR2
Reset Value
IC1HR
Reset Value
IC1LR
Reset Value
OC1HR
Reset Value
OC1LR
Reset Value
OC2HR
Reset Value
OC2LR
Reset Value
CHR
Reset Value
CLR
Reset Value
ACHR
Reset Value
ACLR
Reset Value
IC2HR
Reset Value
IC2LR
Reset Value
76543210
ICIE
0
OC1E
0
ICF1
0
MSB
-
MSB
-
MSB
1
MSB
0
MSB
1
MSB
0
MSB
1111111
MSB
1111110
MSB
1111111
MSB
1111110
MSB
-
MSB
-
OCIE
0
OC2E
0
OCF1
0
------
------
-
0
-
0
-
0
-
0
------
------
TOIE0FOLV20FOLV10OLVL20IEDG10OLVL1
OPM
0
TOF
0
-
0
-
0
-
0
-
0
PWM
0
ICF2
0
-
0
-
0
-
0
-
0
CC1
0
OCF2
0
-
0
-
0
-
0
-
0
CC0
0
-
0
-
0
-
0
-
0
-
0
IEDG20EXEDG
-
0
-
0
-
0
-
0
-
0
0
0
-
0
LSB
-
LSB
-
LSB
0
LSB
0
LSB
0
LSB
0
LSB
1
LSB
0
LSB
1
LSB
0
LSB
-
LSB
-
48/84
48
4.4 SERIAL PERIPHERAL INTERFACE (SPI)
ST72101/ST72212/ST72213
4.4.1 Introduction
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 mastersor slaves.
The SPI is normally used for communication be­tween themicrocontroller and external peripherals or another microcontroller.
Refer to the Pin Descriptionchapter for the device­specific pin-out.
4.4.2 Main Features
Full duplex, three-wire synchronous transfers
Master orslave operation
Four mastermode frequencies
Maximum slave mode frequency = fCPU/2.
Four programmablemaster bit rates
Programmable clock polarity and phase
End of transfer interrupt flag
Write collision flag protection
Master modefault protection capability.
4.4.3 General description
The SPI is connected to external devices through 4 alternate pins:
– MISO: Master In Slave Out pin – MOSI: Master Out Slave In pin – SCK: Serial Clock pin – SS: Slave select pin
A basic example of interconnections between a single master and a single slave is illustrated on Figure 33.
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).
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).
Thus, the byte transmitted is replacedby 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 36) but master and slave must be programmed with the same timing mode.
Figure 33. Serial Peripheral Interface Master/Slave
MASTER
MSBit LSBit MSBit LSBit 8-BIT SHIFT REGISTER
SPI
CLOCK
GENERATOR
MISO
MOSI
SCK
SS
+5V
MISO
MOSI
SCK
SS
SLAVE
8-BIT SHIFT REGISTER
49/84
49
ST72101/ST72212/ST72213
SERIAL PERIPHERAL INTERFACE (Cont’d) Figure 34. Serial Peripheral Interface Block Diagram
Internal Bus
MOSI
MISO
SCK
SS
Read
Read Buffer
8-Bit Shift Register
Write
CONTROL
DR
MASTER
WCOL
SPIF
SPIE SPE SPR2 MSTR CPHA SPR0SPR1CPOL
MODF
-
SPI
STATE
CONTROL
--
IT
request
SR
--
CR
50/84
SERIAL CLOCK GENERATOR
50
SERIAL PERIPHERAL INTERFACE (Cont’d)
4.4.4 Functional Description
Figure 33 shows the serial peripheral interface (SPI) blockdiagram.
This interface contains 3 dedicated registers:
– A Control Register (CR) – A Status Register (SR) – A Data Register (DR)
Refer to the CR, SR and DR registers in Section
4.4.7for the bit definitions.
4.4.4.1 Master Configuration
In a master configuration, the serial clock is gener­ated onthe SCK pin.
Procedure
– Select the SPR0 & SPR1 bits todefine these-
rial clock baud rate (see CR register).
– Select the CPOL and CPHA bits todefine one
of the four relationships between the data transfer and the serial clock (see Figure 36).
– The SS pin must be connected to ahigh level
signal during the complete byte transmit se­quence.
– The MSTR and SPE bits must beset (they re-
main set only if the SS pin is connected to a high level signal).
ST72101/ST72212/ST72213
In this configuration the MOSI pin is a data output and to the MISO pin is a data input.
Transmit sequence
The transmit sequencebegins when abyte is writ­ten the DRregister.
The data byte is parallel loaded into the 8-bit shift register (from the internal bus)during a writecycle and then shifted out serially to the MOSI pin most significant bit first.
When data transfer is complete:
– The SPIF bit is set by hardware – An interrupt is generatedif the SPIE bit is set
and the I bit in the CCR register is cleared.
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. Whenthe DR register isread, the SPI peripheralreturns this buffered value.
Clearing the SPIF bit isperformed bythe following software sequence:
1.An access to the SR registerwhile the SPIF bit is set
2.A write ora read of the DR register.
Note: While the SPIF bit is set, all writes to the DR
51
51/84
ST72101/ST72212/ST72213
SERIAL PERIPHERAL INTERFACE (Cont’d)
4.4.4.2 Slave Configuration
In slave configuration, the serial clock is received on the SCK pin from themaster device.
The value of the SPR0& SPR1 bits is not used for the data transfer.
Procedure
– For correct data transfer, the slave device
must be in the same timing mode asthe mas­ter device (CPOL and CPHA bits).See Figure
36.
– The SS pin must be connected to a low level
signal during the complete byte transmit se­quence.
– Clear the MSTRbit and set the SPE bit to as-
sign the pins to alternate function.
In this configuration the MOSI pin is a data input and theMISO pin is a data output.
Transmit Sequence
The data byte is parallel loaded into the 8-bit shift register (from the internalbus) during a write cycle and then shifted out serially to the MISO pin most significant bit first.
The transmit sequence begins whenthe slave de­vice receivesthe clock signal and the most signifi­cant bit of the data on its MOSI pin.
When data transfer is complete:
– The SPIF bit is set by hardware – An interrupt is generatedif SPIE bit is set and
I bit in CCR register iscleared.
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. Whenthe DR register isread, the SPI peripheralreturns this buffered value.
Clearing the SPIF bit isperformed bythe following software sequence:
1.An access to the SR registerwhile the SPIF bit is set.
2.A write ora read of the DR register.
Notes: While the SPIF bit is set, all writes to the DR register are inhibited until the SR register is read.
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 4.4.4.6).
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 awrite collision(see Section
4.4.4.4).
52/84
52
SERIAL PERIPHERAL INTERFACE (Cont’d)
4.4.4.3 Data Transfer Format
During an SPI transfer, data is simultaneously transmitted (shifted out serially) and received (shifted in serially). Theserial clock isused tosyn­chronize the data transfer during a sequence of eight clockpulses.
The SS pin allows individual selection of a slave device; theother slave devices that are notselect­ed do not interfere with the SPI transfer.
Clock Phase and Clock Polarity
Four possible timing relationships may be chosen by software,using the CPOL and CPHA bits.
The CPOL (clock polarity) bit controls the steady state value of the clock when no data is being transferred. This bit affects both master andslave modes.
The combination between the CPOL and CPHA (clock phase) bits selects the data capture clock edge.
Figure 36, shows an SPI transfer with the four combinations of the CPHAand CPOL bits. Thedi­agram may be interpreted as a master or slave timing diagram where the SCK pin, the MISO pin, the MOSI pin are directly connected between the master and theslave device.
The SS pin is the slavedevice select input andcan be driven by the master device.
ST72101/ST72212/ST72213
The master device applies data to its MOSI pin­clock edge before the capture clockedge.
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 theMSBit capture strobe. Data islatched on the occurrence of the first clock transition.
No write collision should occur even if the SS pin stays low during a transfer of several bytes (see Figure 35).
CPHA bit is reset
The firstedge on theSCKpin (falling edge ifCPOL bit is set, rising edge if CPOL bit is reset) is the MSBit capture strobe. Data is latched on the oc­currence of the second clock transition.
This pin must be toggled high and low between each byte transmitted (see Figure 35).
To protect the transmission froma writecollision 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 35. CPHA / SS Timing Diagram
MOSI/MISO
Master
SS
Slave SS
(CPHA=0)
Slave
SS
(CPHA=1)
Byte 1 Byte 2
Byte 3
VR02131A
53/84
53
ST72101/ST72212/ST72213
SERIAL PERIPHERAL INTERFACE (Cont’d) Figure 36. Data Clock Timing Diagram
CPOL = 1
CPOL =0
CPHA =1
MISO
(from master)
MOSI
(from slave)
SS
(to slave)
CAPTURE STROBE
CPOL = 1
CPOL = 0
MISO
(from master)
MSBit Bit 6 Bit 5
MSBit Bit 6 Bit 5
MSBit Bit 6 Bit 5
Bit 4 Bit3 Bit 2 Bit 1 LSBit
Bit 4 Bit3 Bit 2 Bit 1 LSBit
CPHA =0
Bit 4 Bit3 Bit 2 Bit 1 LSBit
MOSI
(from slave)
SS
(to slave)
CAPTURE STROBE
Note: This figureshould not be usedas a replacement forparametric information. Refer to the Electrical Characteristics chapter.
54/84
54
MSBit Bit 6 Bit 5 Bit 4 Bit3 Bit 2 Bit 1 LSBit
VR02131B
SERIAL PERIPHERAL INTERFACE (Cont’d)
4.4.4.4 Write Collision Error
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.
Write collisions can occurboth inmaster and slave mode.
Note: a ”read collision” will never occur since the received data byte is placed in a buffer in which access is alwayssynchronous withthe MCU oper­ation.
In Slave mode
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 edgewill 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 lowstate 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.
ST72101/ST72212/ST72213
When the CPHA bit is reset: Data is latchedon the occurrence of thefirst 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 registerafter its SS pin has been pulled low.
For this reason, the SS pin mustbe high, between each data byte transfer, to allow the CPU to write in the DR register without generating a write colli­sion.
In Master mode
Collision in the master device is definedas a write of the DR register while the internal serial clock (SCK) is in the process of transfer.
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.
No SPI interrupt is generated when the WCOL bit is set (the WCOL bit is a status flagonly).
Clearing the WCOLbit is done through a software sequence (see Figure37).
Figure 37. Clearing the WCOLbit (Write Collision Flag) Software Sequence
Clearing sequence after SPIF = 1(end of a databyte transfer)
1st Step
2nd Step
Read SR
OR
THEN
Read DR Write DR
SPIF =0 WCOL=0
Read SR
THEN
SPIF =0 WCOL=0 if no transfer has started WCOL=1 if a transfer has started
before the 2nd step
Clearing sequence before SPIF = 1 (during a data byte transfer)
1st Step
2nd Step
Read SR
Read DR
THEN
WCOL=0
Note: Writing in DR register in­stead of reading in it do not reset WCOL bit
55/84
55
ST72101/ST72212/ST72213
SERIAL PERIPHERAL INTERFACE (Cont’d)
4.4.4.5 Master Mode Fault
Master mode fault occurs when the master device has its SS pin pulled low, then the MODF bit isset.
Master mode fault affectstheSPI peripheral in the following ways:
– The MODF bit is set and an SPI interrupt is
generated if theSPIE bit is set.
– The SPE bit is reset. This blocks all output
from the device and disables the SPI periph­eral.
– The MSTR bit is reset,thus forcingthe device
into slave mode.
may be restored to their original state during or af­ter this clearing sequence.
Hardware does not allow the user to set the SPE and MSTR bits while the MODFbit isset exceptin the MODF bit clearing sequence.
In a slave device the MODF bit can notbe set, but in a multi masterconfiguration the device can be in slave mode with this MODF bit set.
The MODF bit indicates that there might have been a multi-master conflict for system control and allows a proper exitfrom systemoperation toa re­set or default system state using an interrupt rou­tine.
Clearing theMODF bit is done through a software sequence:
1. A read or write access to the SR register while the MODF bit is set.
2. A writeto the CR register.
Notes: To avoid any multiple slave conflicts in the case of a system comprising several MCUs, the SS pinmust be pulled high during the clearingse­quence of the MODF bit. The SPE and MSTRbits
4.4.4.6 Overrun Condition
An overrun condition occurs, when themaster de­vice has sent several data bytes and the slavede­vice has not cleared the SPIF bit issuing from the previous data bytetransmitted.
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.
This condition isnot detected by the SPIperipher­al.
56/84
56
SERIAL PERIPHERAL INTERFACE (Cont’d)
4.4.4.7 Single Master and Multimaster Configurations
There are two types of SPI systems: – Single Master System – Multimaster System
For more security, the slave device may respond to the masterwith thereceived data byte. Then the master willreceivethe previous byte backfrom the slave device if all MISO and MOSI pins are con­nected and the slave has not written its DR regis-
Single MasterSystem
A typical single master systemmay beconfigured, using an MCU as the master and four MCUs as slaves (see Figure 38).
The master device selects the individualslave de­vices byusing fourpins ofa parallel port to control the four SS pinsof the slave devices.
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.
ter. Other transmission security methods can use
ports for handshake lines or data bytes with com­mand fields.
Multi-master System
A multi-master 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 multi-master system is principally handled by the MSTR bit in the CRregister and the MODF bit
Note: To prevent a bus conflict on the MISO line
in the SR register.
the master allows only one slave device during a transmission.
ST72101/ST72212/ST72213
Figure 38. Single Master Configuration
SS
SCK
SCK
Slave
MCU
MOSI
MOSI
MISO
MOSI MOSI MOSIMISO MISO MISOMISO
SCK
Master
5V
MCU
SS
Slave
MCU
SS
SS
SCK SCK
Slave MCU
SS
Slave
MCU
57
57/84
ST72101/ST72212/ST72213
SERIAL PERIPHERAL INTERFACE (Cont’d)
4.4.5 LowPower Modes
Mode Description
WAIT
HALT
4.4.6 Interrupts
No effect on SPI. SPI interrupt events cause the device to exit from WAIT mode.
SPI registers are frozen. 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.
Interrupt Event
SPI End of Transfer Event SPIF Master Mode Fault Event MODF Yes No
Event
Flag
Enable
Control
Bit
SPIE
Exit from Wait
Yes No
Note: The SPI interrupt events are connected to the same interrupt vector (see Interrupts chapter). They generate an interrupt if the corresponding Enable Control Bitis set and the I-bitin the CCreg­ister is reset (RIM instruction).
Exit
from
Halt
58/84
58
ST72101/ST72212/ST72213
SERIAL PERIPHERAL INTERFACE (Cont’d)
4.4.7 Register Description CONTROL REGISTER (CR)
Read/Write Reset Value: 0000xxxx (0xh)
70
SPIE SPE SPR2 MSTR CPOL CPHA SPR1 SPR0
Bit 7 = SPIE
Serial peripheral interrupt enable.
This bit is set and cleared by software. 0: Interrupt is inhibited 1: An SPI interruptis generated whenever SPIF=1
or MODF=1in the SR register
Bit 6 = SPE
Serial peripheral output enable.
This bit is set and cleared by software. It is also cleared by hardware when, inmaster mode, SS=0 (see Section 4.4.4.5 Master Mode Fault). 0: I/O port connected to pins 1: SPI alternate functions connected to pins
The SPE bit is clearedby reset,so the SPI periph­eral isnot initially connected to the external pins.
Bit 3 = CPOL
Clock polarity.
This bit is setand cleared by software. This bit de­termines the steady state of the serial Clock. The CPOL bit affects both the master and slave modes. 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 2 = CPHA
Clock phase.
This bit is set andcleared by software. 0: The first clock transition isthe firstdata capture
edge.
1: The second clock transition is the first capture
edge.
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 baudrates to be used as the serial clock when the deviceis a master.
These 2 bits have no effectin slave mode.
Bit 5 = SPR2
Divider Enable
.
this bit is set and cleared by software and it is cleared by reset.It is usedwith theSPR[1:0] bits to set the baud rate. Refer to Table 17. 0: Divider by 2 enabled 1: Divider by 2 disabled
Bit 4 = MSTR
Master.
This bit is set and cleared by software. It is also cleared by hardware when, inmaster mode, SS=0 (see Section 4.4.4.5 Master Mode Fault). 0: Slave mode is selected 1: Master mode is selected, the function of the
SCK pin changesfrom an input to an output and the functions ofthe MISO and MOSI pinsare re­versed.
Table 17. Serial Peripheral Baud Rate
Serial Clock SPR2 SPR1 SPR0
/2 1 0 0
f
CPU
/8 0 0 0
f
CPU
/16 0 0 1
f
CPU
/32 1 1 0
f
CPU
/64 0 1 0
f
CPU
/128 0 1 1
f
CPU
59
59/84
ST72101/ST72212/ST72213
SERIAL PERIPHERAL INTERFACE (Cont’d) STATUS REGISTER (SR)
Read Only Reset Value: 0000 0000 (00h)
DATA I/O REGISTER (DR)
Read/Write Reset Value: Undefined
70
SPIF WCOL - MODF - - - -
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 progressor has beenap-
proved by a clearing sequence.
1: Data transfer between the device and an exter-
nal device has been completed.
Note: While the SPIFbit is set, allwrites to the DR register are inhibited.
Bit 6 = WCOL
Write Collision status.
This bit is set by hardware when a write to the DR
70
D7 D6 D5 D4 D3 D2 D1 D0
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 anotherbyte.
Notes: During the last clock cycle the SPIF bit is set, a copy of the received data byte in the shift register is movedto a buffer. Whenthe user reads the serial peripheral data I/O register, the buffer is actually being read.
Warning:
A write to theDR register places data directly into the shift register fortransmission.
A write to the the DR register returns the value lo­cated in the bufferand notthe contentsof the shift
register (See Figure 34 ). register is done during a transmit sequence. It is cleared by a software sequence (see Figure 37). 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 4.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 accessto 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.
60/84
60
SERIAL PERIPHERAL INTERFACE (Cont’d) Table 18. SPI Register Map and Reset Values
ST72101/ST72212/ST72213
Address
(Hex.)
21
22
23
Register
Name
DR
Reset Value
CR
Reset Value
SR
Reset Value
76543210
D7
x
SPIE
0
SPIF
0
D6
x
SPE
0
WCOL
0
D5
x
SPR20MSTR
-
0
D4
x
0
MODF
0
D3
x
CPOL
x
-
0
D2
x
CPHA
x
-
0
D1
x
SPR1
x
-
0
D0
x
SPR0
x
-
0
61
61/84
ST72101/ST72212/ST72213
4.5 8-BIT A/D CONVERTER (ADC)
4.5.1 Introduction
The on-chip Analog to Digital Converter (ADC) pe­ripheral is a 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 pin out description) that allow the peripheral to convert the analog voltage levels from up to 8 different sources.
The result of the conversion is stored in a 8-bit Data Register. The A/D converter is controlled through a Control/Status Register.
Figure 39. ADC block diagram
AIN0 AIN1
AIN2 AIN3 AIN4 AIN5 AIN6 AIN7
ANALOG
MUX
SAMPLE
&
HOLD
4.5.2 Main Features
8-bit conversion
Up to 8 channels with multiplexed input
Linear successive approximation
Data register (DR) which contains the results
Conversioncomplete status flag
On/off bit (to reduce consumption)
The block diagram is shown in Figure 39.
COCO
0CH0CH1CH2-- ADON
(Control Status Register) CSR
ANALOG TO DIGITAL CONVERTER
62/84
62
f
CPU
AD7
AD4 AD0AD1AD2AD3AD6 AD5
(Data Register) DR
8-BIT A/D CONVERTER (ADC) (Cont’d)
4.5.3 Functional Description
The high level reference voltage V
DDA
must be connected externallyto the VDDpin. The low level reference voltage V
must be connected exter-
SSA
nally to the VSSpin. In some devices (refer to de­vice pin out description) high and low level refer­ence voltages are internally connected to the V and VSSpins.
DD
Conversion accuracy may therefore be degraded by voltage drops and noise in the event of heavily loaded orbadly decoupled power supply lines.
Figure 40. Recommended Ext. Connections
1K
V
DD
0.1µF
V V
DDA
SSA
ST7
R
AIN
V
AIN
Px.x/AINx
Characteristics:
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
DD
(voltage reference high) then results = FFh (full scale) withoutoverflow indication.
If input voltage VSS(voltage reference low) then the results = 00h.
The conversion time is 64 CPU clock cycles in­cluding asampling time of 31.5 CPU clock cycles.
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 alloted time.
ST72101/ST72212/ST72213
The accuracy of the conversion is describedin the Electrical Characteristics Section.
Procedure:
Refer to the CSRand DRregister description sec­tion for the bit definitions.
Each analog input pin must be configured as input, no pull-up, no interrupt. Refer to the «I/O ports» chapter. Using these pins as analog inputs does not affect the abilityof the port to beread as a logic input.
In the CSR register:
– Select the CH2 to CH0 bits to assign the ana-
log channel toconvert. Refer to Table 19.
– Set the ADON bit. Then the A/D converter is
enabled after a stabilization time (typically 30 µs). It then performs a continuous conversion of the selected channel.
When a conversionis complete
– The COCO bit is set by hardware. – No interrupt isgenerated. – The result is in the DR register.
A write to the CSR register aborts the current con­version, resets the COCO bit and starts a new conversion.
4.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.
Mode Description
WAIT No effect on A/D Converter
A/D Converterdisabled. After wakeup from Halt mode, theA/D
HALT
Converter requires a stabilisation time before accurate conversionscan be performed.
The A/D converter is linear and the digital result of the conversion is given by theformula:
Digital result =
255 x Input Voltage Reference Voltage
Where Reference Voltage is VDD-VSS.
4.5.5 Interrupts
None
63/84
63
ST72101/ST72212/ST72213
8-BIT A/D CONVERTER (ADC) (Cont’d)
4.5.6 Register Description CONTROL/STATUS REGISTER (CSR)
Read/Write Reset Value: 0000 0000 (00h)
70
COCO - ADON 0 - CH2 CH1 CH0
Bit 7 = COCO
Conversion Complete
This bit is set by hardware. It is cleared by soft­ware readingthe resultin the DRregister or writing to the CSR register. 0: Conversion is not complete. 1: Conversion can be read from theDR register.
These bits are set and cleared by software. They select the analog input to convert.
Table 19. Channel Selection
Pin* CH2 CH1 CH0
AIN0 0 0 0 AIN1 0 0 1 AIN2 0 1 0 AIN3 0 1 1 AIN4 1 0 0 AIN5 1 0 1 AIN6 1 1 0 AIN7 1 1 1
Bit 6 = Reserved. Must always be cleared.
Bit 5 = ADON
A/D converter On
This bit is set and cleared by software. 0: A/D converter is switched off. 1: A/D converter is switched on.
Note: a typically 30µs delay time is necessary for the ADC tostabilize when the ADON bit is set.
Bit 4 = Reserved. Forced by hardware to 0.
Bit 3 = Reserved. Must always be cleared.
Bits 2-0:CH[2:0]
Channel Selection
Table 20. ADC Register Map
Address
(Hex.)
70
Reset Value
71
Reset Value
Register
Name
DR
CSR
765 43210
AD7
0
COCO
0
AD6
0
-
0
ADON
*IMPORTANT NOTE:
The number of pins AND the channel selection vary according to the device. REFER TO THEDEVICE PINOUT).
DATA REGISTER (DR)
Read Only Reset Value: 0000 0000 (00h)
70
AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0
Bit 7:0 = AD[7:0]
Analog Converted Value
This register contains the converted analog value in the range 00h to FFh.
Reading this registerreset the COCOflag.
AD5
0
0
AD4
0 0
0
AD3
0
-
0
AD2
0
CH2
0
AD1
0
CH1
0
AD0
0
CH0
0
64/84
64
5 INSTRUCTION SET
ST72101/ST72212/ST72213
5.1 ST7 ADDRESSING MODES
The ST7 Core features 17 different addressing modes which can be classified in7 main groups:
Addressing Mode Example
Inherent nop Immediate ld A,#$55 Direct ld A,$55 Indexed ld A,($55,X) Indirect ld A,([$55],X) Relative jrne loop Bit operation bset byte,#5
The ST7 Instruction set is designed to minimize
so, most of the addressing modes may be subdi­vided in two sub-modes called long andshort:
– Longaddressing mode is more powerful be-
cause itcan use thefull64 Kbyte addressspace, however it uses more bytes and more CPU cy­cles.
– Short addressing mode isless powerfulbecause
it can generally only access page zero (0000h ­00FFh range),but the instruction size ismore compact, andfaster. 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)
The ST7 Assembler optimizes the use of long and short addressing modes.
the number ofbytes requiredper instruction: To do
Table 21. ST7 Addressing Mode Overview
Mode Syntax
Inherent nop + 0 Immediate ld A,#$55 + 1 Short Direct ld A,$10 00..FF + 1 Long Direct ld A,$1000 0000..FFFF + 2
No Offset Direct Indexed ld A,(X) 00..FF Short Direct Indexed ld A,($10,X) 00..1FE + 1
Long Direct Indexed ld A,($1000,X) 0000..FFFF + 2 Short Indirect ld A,[$10] 00..FF 00..FF byte + 2 Long Indirect ld A,[$10.w] 0000..FFFF 00..FF word + 2 Short Indirect Indexed ld A,([$10],X) 00..1FE 00..FF byte + 2 Long Indirect Indexed ld A,([$10.w],X) 0000..FFFF 00..FF word + 2 Relative Direct jrne loop PC-128/PC+127 Relative Indirect jrne [$10] PC-128/PC+127 Bit Direct bset $10,#7 00..FF + 1 Bit Indirect bset [$10],#7 00..FF 00..FF byte + 2 Bit Direct Relative btjt $10,#7,skip 00..FF + 2 Bit Indirect Relative btjt [$10],#7,skip 00..FF 00..FF byte + 3
Destination/
Source
Pointer
Address
(Hex.)
1)
1)
00..FF byte + 2
Pointer
Size
(Hex.)
Length
(Bytes)
+ 0 (with X register) + 1 (with Y register)
+1
Note 1. At the time the instruction is executed,the Program Counter (PC) points to the instructionfollow­ing JRxx.
65
65/84
ST72101/ST72212/ST72213
ST7 ADDRESSING MODES (Cont’d)
5.1.1 Inherent
All Inherent instructions consist of a single byte. The opcode fully specifies all the required informa­tion for theCPU to process the operation.
Inherent Instruction Function
NOP No operation TRAP S/W Interrupt
WFI
HALT RET Sub-routine Return
IRET Interrupt Sub-routine Return SIM Set Interrupt Mask RIM Reset Interrupt Mask SCF Set Carry Flag RCF Reset Carry Flag RSP Reset Stack Pointer LD Load CLR Clear PUSH/POP Push/Pop to/from the stack INC/DEC Increment/Decrement TNZ Test Negative or Zero CPL, NEG 1 or 2 Complement MUL Byte Multiplication SLL, SRL, SRA, RLC,
RRC SWAP Swap Nibbles
5.1.2 Immediate
Immediate instructions have two bytes, the first byte contains the opcode, the second byte con­tains the the operand value. .
Immediate Instruction Function
LD Load CP Compare BCP Bit Compare AND, OR, XOR Logical Operations ADC, ADD, SUB, SBC Arithmetic Operations
Wait For Interrupt (Low Power Mode)
Halt Oscillator (Lowest Power Mode)
Shift and Rotate Operations
5.1.3 Direct
In Direct instructions, theoperands are referenced by their memory address.
The direct addressing mode consists of two sub­modes:
Direct (short)
The address is a byte, thus requires only one byte after the opcode, but only allows 00 - FF address­ing space.
Direct (long)
The address is a word, thus allowing 64 Kbyte ad­dressing space, but requires 2 bytes after the op­code.
5.1.4 Indexed (No Offset, Short, Long)
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.
The indirect addressing mode consists of three sub-modes:
Indexed (No Offset)
There is nooffset, (noextra byteafter the opcode), and allows 00 - FF addressingspace.
Indexed (Short)
The offset is a byte, thus requires only one byteaf­ter the opcode and allows 00 - 1FE addressing space.
Indexed (long)
The offset is a word, thus allowing 64 Kbyte ad­dressing space and requires 2 bytes after the op­code.
5.1.5 Indirect (Short, Long)
The required data byteto do the operation is found by itsmemory address, located in memory (point­er).
The pointer address follows the opcode. The indi­rect addressing mode consists of two sub-modes:
Indirect (short)
The pointer addressis a byte, thepointer size is a byte, thus allowing 00 - FFaddressing space, and requires 1 byteafter the opcode.
Indirect (long)
The pointer addressis a byte, thepointer size is a word, thus allowing 64 Kbyte addressing space, and requires 1 byte after the opcode.
66/84
66
ST7 ADDRESSING MODES (Cont’d)
5.1.6 Indirect Indexed (Short, Long)
This is acombination 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 apointer value located in memory. The point­er address followsthe opcode.
The indirect indexed 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 requires1 byte after the opcode.
Indirect Indexed(Long)
The pointer address is a byte, the pointer size is a word, thus allowing 64 Kbyte addressing space, and requires1 byte after the opcode.
Table 22. Instructions Supporting Direct, Indexed, Indirect and Indirect Indexed Addressing Modes
ST72101/ST72212/ST72213
5.1.7 Relative mode (Direct, Indirect)
This addressing mode is used to modify the PC register value, by adding an 8-bit signed offset to it.
Available Relative Direct/
Indirect Instructions
JRxx Conditional Jump CALLR Call Relative
The relative addressing mode consists oftwo sub­modes:
Relative (Direct)
The offset is following the opcode.
Relative (Indirect)
The offset is defined in memory, which address follows the opcode.
Function
Long and Short
Instructions
LD Load CP Compare AND, OR, XOR Logical Operations
ADC, ADD, SUB, SBC BCP Bit Compare
Short Instructions Only Function
CLR Clear INC, DEC Increment/Decrement TNZ Test Negative or Zero CPL, NEG 1 or 2 Complement BSET, BRES Bit Operations
BTJT, BTJF SLL, SRL, SRA, RLC,
RRC SWAP Swap Nibbles CALL, JP Call or Jump subroutine
Arithmetic Addition/subtrac­tion operations
Bit Test and Jump Opera­tions
Shift and Rotate Operations
Function
67
67/84
ST72101/ST72212/ST72213
5.2 INSTRUCTION GROUPS
The ST7 family devices use an Instruction Set consisting of 63 instructions. The instructions may
Load and Transfer LD CLR Stack operation PUSH POP RSP Increment/Decrement INC DEC Compare and Tests CP TNZ BCP Logical operations AND OR XOR CPL NEG Bit Operation BSET BRES Conditional Bit Test and Branch BTJT BTJF Arithmetic operations ADC ADD SUB SBC MUL Shift and Rotates SLL SRL SRA RLC RRC SWAP SLA Unconditional Jump or Call JRA JRT JRF JP CALL CALLR NOP RET Conditional Branch JRxx Interruption management TRAP WFI HALT IRET Code Condition Flag modification SIM RIM SCF RCF
be subdivided into 13 main groups as illustrated in the following table:
Using a pre-byte
The instructions are described with one to four bytes.
In order to extend the number of available op­codes for an 8-bitCPU (256opcodes), three differ­ent prebyte opcodes are defined. These prebytes modify the meaning of the instruction they pre­cede.
The whole instruction becomes:
PC-2 End of previous instruction PC-1 Prebyte PC opcode
PC+1 Additional word (0 to 2) according to the numberof bytesrequired tocompute the ef­fective address
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:
PDY 90 Replace an X based instruction using immediate, direct, indexed, or inherent ad­dressing mode by a Y one.
PIX 92 Replace an instruction using di­rect, direct bit, or direct relative addressing mode to an instruction using the corresponding indirect addressing mode. It also changesan instruction using Xindexed ad­dressing modeto an instruction using indirect Xin­dexed addressing mode.
PIY 91 Replace an instruction using X in­direct indexed addressing mode by a Y one.
68/84
68
ST72101/ST72212/ST72213
INSTRUCTION GROUPS (Cont’d)
Mnemo Description Function/Example Dst Src H I N Z C
ADC Add with Carry A = A + M + C A M H N Z C ADD Addition A = A + M A M H N Z C AND Logical And A = A . M A M N Z BCP Bit compare A, Memory tst (A . M) A M N Z BRES Bit Reset bres Byte, #3 M BSET Bit Set bset Byte, #3 M BTJF Jump if bit is false (0) btjf Byte, #3, Jmp1 M C BTJT Jump if bit is true (1) btjt Byte, #3, Jmp1 M C CALL Call subroutine CALLR Call subroutine relative CLR Clear reg, M 0 1 CP Arithmetic Compare tst(Reg - M) reg M N Z C CPL One Complement A = FFH-A reg, M N Z 1 DEC Decrement dec Y reg, M N Z HALT Halt 0 IRET Interrupt routine return Pop CC, A,X, PC H I N Z C INC Increment inc X reg, M N Z JP Absolute Jump jp [TBL.w] JRA Jump relative always JRT Jump relative JRF Never jump jrf * JRIH Jump if ext. interrupt = 1 JRIL Jump if ext. interrupt = 0 JRH Jump if H = 1 H = 1? JRNH Jump if H = 0 H = 0? JRM Jump if I = 1 I = 1 ? JRNM Jump if I = 0 I = 0 ? JRMI Jump if N = 1(minus) N = 1? JRPL Jump if N = 0(plus) N = 0? JREQ Jump if Z = 1 (equal) Z = 1 ? JRNE Jump if Z = 0 (not equal) Z =0 ? JRC Jump if C = 1 C = 1? JRNC Jump if C = 0 C = 0? JRULT Jump if C = 1 Unsigned < JRUGE Jump if C = 0 Jmp if unsigned >= JRUGT Jump if (C + Z = 0) Unsigned >
69
69/84
ST72101/ST72212/ST72213
INSTRUCTION GROUPS (Cont’d)
Mnemo Description Function/Example Dst Src H I N Z C
JRULE Jump if (C + Z = 1) Unsigned <= LD Load dst <= src reg, M M, reg N Z MUL Multiply X,A =X * A A, X, Y X, Y, A 0 0 NEG Negate (2’s compl) neg $10 reg, M N Z C NOP No Operation OR OR operation A = A + M A M N Z POP Pop from the Stack pop reg reg M
pop CC CC M H I N Z C PUSH Push onto the Stack push Y M reg, CC RCF Reset carry flag C = 0 0 RET Subroutine Return RIM Enable Interrupts I = 0 0 RLC Rotate left true C C <= Dst <= C reg, M N Z C RRC Rotate right true C C => Dst => C reg, M N Z C RSP Reset Stack Pointer S = Max allowed SBC Subtract with Carry A = A - M -C A M N Z C SCF Set carry flag C = 1 1 SIM Disable Interrupts I = 1 1 SLA Shift left Arithmetic C <= Dst <= 0 reg, M N Z C SLL Shift left Logic C <= Dst <= 0 reg, M N Z C SRL Shift right Logic 0 => Dst => C reg, M 0 Z C SRA Shift right Arithmetic Dst7 => Dst => C reg, M N Z C SUB Subtraction A = A - M A M N Z C SWAP SWAP nibbles Dst[7..4] <=> Dst[3..0] reg, M N Z TNZ Test for Neg & Zero tnz lbl1 N Z TRAP S/W trap S/W interrupt 1 WFI Wait for Interrupt 0 XOR Exclusive OR A = A XOR M A M N Z
70/84
70
6 ELECTRICAL CHARACTERISTICS
6.1 ABSOLUTE MAXIMUM RATINGS
ST72101/ST72212/ST72213
This product contains devices to protect the inputs against damage due to high static voltages, how­ever it is advisable to take normal precaution to avoid application of any voltage higher than the specified maximum ratedvoltages.
Power Considerations.The average chip-junc­tion temperature, TJ, in Celsius can be obtained from:
TJ= TA + PD x RthJA
Where: TA= Ambient Temperature.
For proper operation it is recommended that V and VObe higher than VSSand lower than VDD. Reliability is enhanced if unused inputs are con­nected to an appropriate logic voltage level (V or VSS).
Symbol Parameter Value Unit
V
DD
V
I
V
AI
V
O
IV
DD
IV
SS
T
J
T
STG
Note: Stresses above those listed as “absolute maximum ratings” may cause permanent damage to thedevice. This is
a stress rating only and functional operation ofthe device atthese conditions isnot implied. Exposure to maximum rating conditions for extended periods may affect device reliability.
Supply Voltage -0.3 to6.0 V Input Voltage VSS- 0.3 to VDD+ 0.3 V Analog Input Voltage (A/D Converter) VSS- 0.3 to VDD+ 0.3 V Output Voltage VSS- 0.3 to VDD+ 0.3 V TotalCurrent into VDD(source) 80 mA TotalCurrent out of VSS(sink) 80 mA Junction Temperature 150 °C Storage Temperature -60 to 150 °C
DD
I
RthJA = Package thermal resistance
(junction-to ambient). PD=P P
INT=IDDxVDD
P
PORT
INT+PPORT
=Portpower dissipation
determined by the user)
.
(chip internal power).
71
71/84
ST72101/ST72212/ST72213
6.2 RECOMMENDED OPERATING CONDITIONS
Symbol Parameter Test Conditions
1 Suffix Version 0 70 °C
T
V
f
OSC
Note 1: A/D operation and Oscillator start-up are not guaranteed below 1MHz.
Operating Temperature
A
Operating Supply Voltage
DD
Oscillator Frequency
6 Suffix Version -40 85 °C 3 Suffix Version -40 125 °C
=16 MHz (1 & 6 Suffix)
f
OSC
f
=8 MHz
OSC
= 3.0V
V
DD
V
= 3.5V (1 & 6 Suffix)
DD
Value
Min. Typ. Max.
3.5
3.0 0
0
1)
1)
5.5
5.5 8
16
Unit
V
MHz
Figure 41. Maximum Operating Frequency (f
FUNCTIONALITY NOT GUARANTEED IN THISAREA
f
OSC
[MHz]
16
8
4
1 0
2.5 3 3.5 4 4.5 5 5.5
FUNCTIONALITY NOT GUARANTEED IN THIS AREA
FOR TEMPERATURE HIGHER THAN85°C
FUNCTIONALITY NOT GUARANTEED IN THIS AREAWITH RESONATOR
) Versus Supply Voltage (VDD)
OSC
FUNCTIONALITY GUARANTEED IN THIS AREA
Supplly Voltage
[V]
72/84
72
6.3 DC ELECTRICAL CHARACTERISTICS
(TA= -40°C to+125°C and VDD= 5Vunless otherwise specified)
ST72101/ST72212/ST72213
4.9
4.2
20 60
Value
400 mV
0.1
0.4
0.1
1.5
3.0
3.0
0.1 1.0
0.1 1.0 40
12080240 100 k
3
5.5 10
1.5
2.5
4 2
3.5
6
0.8
1
1.6
1 5
6 11 20
3
5
8
4
7 12
1.5 2
3.5
10 20
Unit
V
V
µA
k
mA
mA
mA
mA
µA
Symbol Parameter Test Conditions
V
V
V
V
R
R
I
V
IH
HYS
OL
OH
I
IL
I
IH
I
IH
ON
PU
DD
Input Low Level Voltage
IL
All Input pins Input High LevelVoltage
All Input pins Hysteresis Voltage
All Input pins Low Level Output Voltage
All Output pins
Low Level Output Voltage High Sink I/O pins
High Level Output Voltage All Output pins
Input Leakage Current All Input pins but RESET
Input Leakage Current RESET pin
Reset Weak Pull-up R I/O Weak Pull-up R Supply Current in
RUN Mode
2)
Supply Current in SLOW Mode
Supply Current in WAIT Mode
Supply Current in WAIT-MINI­MUM Mode
5)
Supply Current in HALTMode
1)
4)
ON
PU
3V < V
3V < V
< 5.5V VDDx 0.3 V
DD
< 5.5V VDDx 0.7 V
DD
IOL=+10µA I
= + 2mA
OL
=+10µA
I
OL
I
= +10mA
OL
I
= + 15mA
OL
I
= + 20mA, TA=85°Cmax
OL
IOH=-10µA I
= - 2mA
OH
VIN=VSS(No Pull-up configured) V
IN=VDD
V
IN=VDD
VIN>V
IH
VIN<V
IL
VIN<V
IL
f
= 4 MHz, f
OSC
f
= 8 MHz, f
OSC
f
= 16 MHz, f
OSC
f
= 4 MHz, f
OSC
2)
f
= 8 MHz, f
OSC
f
= 16 MHz, f
OSC
f
= 4MHz, f
OSC
3)
f
= 8MHz, f
OSC
f
= 16MHz, f
OSC
f
= 4 MHz, f
OSC
f
= 8 MHz, f
OSC
f
= 16 MHz, f
OSC
=0mA,TA=85°Cmax
I
LOAD
I
=0mA
LOAD
CPU CPU
CPU
CPU CPU
CPU
CPU CPU
CPU
CPU CPU
CPU
=2MHz =4MHz
= 8 MHz
= 125 kHz = 250 kHz
= 500 kHz
= 2MHz = 4 MHz
=8MHz
= 125 kHz = 250 kHz
= 500 kHz
Min. Typ. Max.
Notes:
1. Hysteresis voltage between switching levels. Based on characterisation results, not tested.
2. CPU running with memory access, no DC load or activity on I/O’s; clockinput (OSCIN) driven by external square wave.
3. No DCload or activity on I/O’s; clock input (OSCIN) driven by external square wave.
4. Except OSCIN and OSCOUT
5. WAIT Mode with SLOW Mode selected. Based oncharacterisation results, not tested.
73
73/84
ST72101/ST72212/ST72213
6.4 RESET CHARACTERISTICS
(TA=-40...+125oC and VDD=5V±10% unless otherwisespecified.
Symbol Parameter Conditions Min Typ
VIN>V
R
t
RESET
t
PULSE
Reset Weak Pull-up R
ON
Pulse duration generated by watch­dog and POR reset
Minimum pulse duration to be ap­plied on external RESET pin
ON
VIN<V
IH IL
Note:
1) These values given only as design guidelines and are not tested.
6.5 OSCILLATOR CHARACTERISTICS
(TA= -40°C to+125°C unless otherwise specified)
Symbol Parameter Test Conditions
g
f
OSC
t
START
Oscillator transconductance 2 9 mA/V
m
Crystal frequency 1 16 MHz Osc. start up time VDD=5V±10% 50 ms
Min. Typ. Max.
10
20 60
1)
Value
1)
Max Unit
40
120
80
240
1 µs
k
ns
Unit
74/84
74
ST72101/ST72212/ST72213
6.6 A/D CONVERTER CHARACTERISTICS (ST72212 and ST72213 only)
(TA= -40°C to+125°C and VDD=5V±10% unlessotherwise specified )
Symbol Parameter Conditions Min Typ Max Unit
T
SAMPLE
Res ADC Resolution
DLE Differential Linearity Error* ±0.6 ±1 ILE Integral Linearity Error* ±2 V
AIN
I
ADC
t
STAB
t
CONV
R
AIN
C
HOLD
R
SS
*Note: For I
inj-
a lossof 1 LSB by 10Kincrease of the external analog source impedance. These measurement results and recommendations take worst case injection conditions into account:
- negative injection
- injectionto an Input with analogcapability, adjacent to the enabled Analog Input
-at5VVDDsupply, and worst case temperature.
Sample Duration 31.5 1/f
f
=8MHz
CPU
V
DD=VDDA
Analog Input Voltage V
=5V
SSA
Supply current rise during A/Dconversion
=8MHz
f
Stabilization timeafter ADC enable 30 µs
CPU
V
DD=VDDA
=5V
Conversion Time
Resistance of analog sources (V
AIN)
Hold Capacitance 22 pF
f
=8MHz, T=25°C,
CPU
V
DD=VDDA
=5V Resistance ofsampling switch and internal trace
ADC Accuracyvs. Negative Injection Current
:
8 bit
V
DDA
V
1mA
8
64
µs 1/f
15 ΚΩ
2 ΚΩ
=0.8mA, the typical leakageinduced inside the die is 1.6µA and theeffect on the ADC accuracy is
CPU
CPU
V
AIN
C
pin
V
T
SS C
hold
leakage
R
AIN
= input capacitance = threshold voltage
= sampling switch = sample/hold
capacitance
= leakage current
at the pin due to various junctions
Px.x/AINx
C
pin
5pF
V
DD
VT= 0.6V
= 0.6V
V
T
Sampling
SS
leakage max.
±1µA
Switch
2ΚΩ
R
SS
C
hold
22 pF
V
SS
75/84
75
ST72101/ST72212/ST72213
A/D CONVERTER CHARACTERISTICS (Cont’d) Figure 42. ADC conversion characteristics
255 254 253 252
251 250
code out
7 6
5 4
3 2
1 0
Offset Error OSE
Offset Error OSE
(2)
1LSB
(1)
(5)
(4)
(3)
1 LSB(ideal)
1 2 3 4 5 6 7 250 251252 253 254 255 256
(1) Example of an actual transfer curve (2) The ideal transfer curve (3) Differential non-linearity error (DLE) (4) Integral non-linearity error (ILE) (5) Center of a step of the actual transfer curve
V
in(A)
(LSB
ideal
)
Gain Error GE
V
refPVrefM
ideal
--------------------------------------- -=
256
VR02133A
76/84
76
6.7 SPI CHARACTERISTICS
ST72101/ST72212/ST72213
Serial Peripheral Interface
Ref. Symbol Parameter Condition
f
SPI
1t 2t
3t 4t
5t
6t
7t
8t
9t
10 t
11 t
12 t
13 t
SPI
Lead
Lag
SPI_H
SPI_L
SU
H
A
Dis
V
Hold
Rise
Fall
SPI frequency
SPI clock period Enable lead time Slave 120 ns
Enable lag time Slave 120 ns Clock (SCK) high time
Clock (SCK) low time
Data set-up time
Data hold time (inputs) Access time (time to data active
from high impedance state) Disable time (hold time to high im-
pedance state) Data valid
Data hold time (outputs) Rise time
(20% V
to 70% VDD,CL=200pF)
DD
Fall time (70% V
to 20% VDD,CL=200pF)
DD
Master Slave
Master Slave
Master Slave
Master Slave
Master Slave
Master Slave
Slave
Master (before capture edge) Slave (after enableedge)
Master (before capture edge) Slave (after enableedge)
Outputs: SCK,MOSI,MISO Inputs: SCK,MOSI,MISO,SS
Outputs: SCK,MOSI,MISO Inputs: SCK,MOSI,MISO,SS
Value
Min. Max.
1/128
dc
1/4 1/2
4 2
100
90
100
90
100 100
100 100
0 120 ns
240 ns
0.25 120
0.25
0
100 100
100 100
Unit
f
CPU
t
CPU
ns
ns
ns
ns
t
CPU
ns
t
CPU
ns ns
µs ns
µs
Measurement points are VOL,VOH,VILand VIHin the SPI Timing Diagram
Figure 43. SPI Master Timing Diagram CPHA=0, CPOL=0
SS
(INPUT)
SCK
(OUTPUT)
MISO
(INPUT)
MOSI
(OUTPUT)
4
D7-IN D6-IN
67
D7-OUT D6-OUT D0-OUT
10 11
1
5
1213
D0-IN
VR000109
77/84
77
ST72101/ST72212/ST72213
SPI CHARACTERISTICS (Cont’d)
Measurement points are VOL,VOH,VILand VIHin the SPI Timing Diagram
Figure 44. SPI Master Timing Diagram CPHA=0, CPOL=1
SS
(INPUT)
SCK
(OUTPUT)
MISO
(INPUT)
MOSI
(OUTPUT)
10 11
D7-IN D6-IN
6
D7-OUT D6-OUT D0-OUT
Figure 45. SPI Master Timing Diagram CPHA=1, CPOL=0
SS
(INPUT)
SCK
(OUTPUT)
MISO
(INPUT)
MOSI
(OUTPUT)
6
D7-IN
10 11
1
45
7
1
54
D7-OUT D6-OUT
7
D6-IN D0-IN
1213
1213
D0-IN
VR000110
D0-OUT
VR000107
Figure 46. SPI Master Timing Diagram CPHA=1, CPOL=1
SS
(INPUT)
SCK
(OUTPUT)
MISO
(INPUT)
MOSI
(OUTPUT)
5
D7-IN D6-IN
6
D7-OUT D6-OUT D0-OUT
10 11
1
4
7
12
13
D0-IN
VR000108
78/84
ST72101/ST72212/ST72213
SPI CHARACTERISTICS (Cont’d)
Measurement points are VOL,VOH,VILand VIHin the SPI Timing Diagram
Figure 47. SPI Slave Timing Diagram CPHA=0, CPOL=0
SS
(INPUT)
SCK
(INPUT)
MISO
(OUTPUT)
(INPUT)
HIGH-Z
8
MOSI
Figure 48. SPI Slave Timing Diagram CPHA=0, CPOL=1
SS
(INPUT)
SCK
(INPUT)
MISO
(OUTPUT)
MOSI
(INPUT)
HIGH-Z
8
2
4
D7-OUT
10
D7-IN
6
2
6
7
54
D7-OUT
10 11
D7-IN
7
1
5
1
13
D6-OUT D0-OUT
11
D6-IN D0-IN
12
D6-OUT D0-OUT
D6-IN D0-IN
12
13
3
9
VR000113
3
9
VR000114
Figure 49. SPI Slave Timing Diagram CPHA=1, CPOL=0
SS
(INPUT)
SCK
(INPUT)
MISO
(OUTPUT)
MOSI
(INPUT)
2
HIGH-Z
8 9
D7-OUT
D7-IN
6
1
54
10
7
D6-OUT D0-OUT
D6-IN D0-IN
Figure 50. SPI Slave Timing Diagram CPHA=1, CPOL=1
SS
(INPUT)
SCK
(INPUT)
MISO
(OUTPUT)
MOSI
(INPUT)
2
HIGH-Z
8
1
54
D7-OUT D6-OUT
D7-IN D6-IN D0-IN
67
10
13
11
12 13
11
12
3
3
D0-OUT
VR000111
9
VR000112
79/84
ST72101/ST72212/ST72213
7 GENERAL INFORMATION
7.1 EPROM ERASURE
EPROM version 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 current.
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 mayalso cause erasure.
An opaque coating (paint, tape, label, etc...) should be placed over the package window if the product is to beoperated undertheselighting con­ditions. Covering the window also reduces IDDin power-saving modes due to photo-diode leakage currents.
An Ultraviolet source of wave length 2537 Å yield­ing a total integrated dosageof 15 Watt-sec/cm2is required to erase the device. It will beerased in 15 to 20 minutes ifsuch aUV lamp with a 12mW/cm power rating is placed 1 inch from the device win­dow without any interposed filters.
7.2 PACKAGE MECHANICAL DATA Figure 51. 28-Pin Small Outline Package, 300-mil Width
SO28
Dim.
A 2.35 2.65 0.0926 0.1043
A1 0.10 0.30 0.0040 0.0118
B 0.33 0.51 0.013 0.020 C 0.23 0.32 0.0091 0.0125 D 17.70 18.10 0.6969 0.7125 E 7.40 7.60 0.2914 0.2992
e 1.27 0.0500
H 10.01 10.64 0.394 0.419
h 0.25 0.74 0.010 0.029
K 0° 8°
L 0.41 1.27 0.016 0.050
G 0.10 0.004
N28
mm inches
Min Typ Max Min Typ Max
Number of Pins
2
80/84
Figure 52. 32-Pin Shrink Plastic Dual In Line Package
ST72101/ST72212/ST72213
E
See Lead Detail
C
e
b1
b
e
3
A
e
B
D
A
N
E
1
2
A
1
e
1
N/2
VR01725J
Figure 53. 32-Pin Shrink Ceramic Dual In-Line Package
CDIP32SW
Dim.
A 3.56 3.76 5.08 0.140 0.148 0.200 A1 0.51 0.020 A2 3.05 3.56 4.57 0.120 0.140 0.180
b 0.36 0.46 0.58 0.014 0.018 0.023
b1 0.76 1.02 1.40 0.030 0.040 0.055
C 0.20 0.25 0.36 0.008 0.010 0.014
D 27.43 27.94 28.45 1.080 1.100 1.120
E 9.91 10.41 11.05 0.390 0.410 0.435
E1 7.62 8.89 9.40 0.300 0.350 0.370
e 1.78 0.070
A
L
eA 10.16 0.400 eB 12.70 0.500
L 2.54 3.05 3.81 0.100 0.120 0.150
N32
Dim.
A 3.63 0.143 A1 0.38 0.015
B 0.36 0.46 0.58 0.014 0.018 0.023 B1 0.64 0.89 1.14 0.025 0.035 0.045
C 0.20 0.25 0.36 0.008 0.010 0.014
D 29.41 29.97 30.53 1.158 1.180 1.202 D1 26.67 1.050
E 10.16 0.400
E1 9.45 9.91 10.36 0.372 0.390 0.408
e 1.78 0.070
G 9.40 0.370 G1 14.73 0.580 G2 1.12 0.044
L 3.30 0.130
Ø 7.37 0.290
N32
mm inches
Min Typ Max Min Typ Max
Number of Pins
mm inches
Min Typ Max Min Typ Max
Number of Pins
81/84
ST72101/ST72212/ST72213
7.3 ORDERING INFORMATION
Each deviceis available forproduction in user pro­grammable version (OTP) as well as in factory coded version (ROM). OTPdevices areshipped to customer with a default blank content FFh, while ROM factory coded partscontain thecode sentby customer. There is one common EPROM version for debugging and prototyping which features the maximum memory size and peripherals of the family. Care must be taken to only use resources available on the target device.
7.3.1 Transfer Of Customer Code
Customer code is made up of the ROM contents and the list of the selected options (if any). The
Figure 54. ROM Factory Coded Device Types
DEVICE
PACKAGE
TEMP.
RANGE
XXX/
Code name (defined by STMicroelectronics) 1 = standard 0 to +70°C
3 = automotive -40 to +125°C 6 = industrial -40 to +85°C
B = Plastic DIP M = Plastic SOIC
ST72101G1 ST72101G2 ST72212G2 ST72213G1
ROM contents are to be sent on diskette, or by electronic means,with thehexadecimal file in .S19 format generated by the development tool. All un­used bytes must be set to FFh.
The selected options are communicated to STMi­croelectronics using the correctly completed OP­TION LIST appended.
The STMicroelectronics Sales Organization will be pleased to provide detailed information on con­tractual points.
Figure 55. OTP User Programmable Device Types
DEVICE
PACKAGE
TEMP.
RANGE
XXX
Option (if any) 3 = automotive -40 to +125°C
6 = industrial -40 to +85°C B = Plastic DIP
M = Plastic SOIC ST72T101G1
ST72T101G2 ST72T212G2 ST72T213G1
Note: TheST72E251G2D0 (CERDIP 25 °C) is used as the EPROMversion for the above devices.
82/84
ST72101/ST72212/ST72213
ST72101, ST72213 and ST72212 MICROCONTROLLER OPTION LIST
Customer . . . .. . . . . . . .. . . . . . . . . . . . . . . ..
Address . . . . . . . . . . . .. . . . . . . . . . . . . . . . .
.............................
Contact . . . . . . . . . . . . . . . . . . . . . . . . .. . . .
Phone No . . . .. . . . . . . . . . . . . . . . . . . .. . . ..
Reference . . . . . . . . . . . .. . . . . . .. . . . . . . . . .
STMicroelectronics references Device: [ ] ST72101 [ ] ST72212 [ ] ST72213 Package: [ ] Dual in Line Plastic [ ] Small OutlinePlastic with conditioning:
[ ] Standard (Stick)
[ ] Tape & Reel Temperature Range: [ ] 0°Cto+70°C []-40°Cto+85°C[]-40°C to+ 125°C Special Marking: [ ] No [ ] Yes ”_ _ _ _ _______” Authorized characters are letters, digits, ’.’,’-’, ’/’ and spaces only. Maximum character count: SDIP32: 10
SO28: 8
Comments: Supply Operating Range in the application: Oscillator Frequency in the application:
Notes . . . . . . . . . . . .. . . . . . .. . . . . . . . . .
Signature . . . . . . . . . . . .. . . . . . . . . . . . . . . . .
Date . . . .. . . . . . . .. . . . . . .. . . . . . . . . .
83/84
ST72101/ST72212/ST72213
8 SUMMARY OF CHANGES
Change Description (Rev. 1.5 to 1.6) Page
Added new External Connections section 9 Removed RP external resistor 16 Changed ORed to ANDed in External interrupts paragraph, to read “If several inputpins, con-
nected to the sameinterrupt vector, areconfigured asinterrupts, their signals are logically AN­Ded before entering the edge/level detection block”.
18 and 24
Added note ”Any modification ofone of these two bits resets the interrupt request related to this interrupt vector.”
23
Added clamping diodes to I/O pin figure andtable 26 Added sections on low power modes and interrupts to peripheral descriptions 31,43,58,63 Changed 16-bit Timer Chapter 32 to 48 Added details to description of FOLV1 and FOLV2 bits 44 Added ADC recommended external connections 63 Added Reset characteristics section 74 Added figure to ADC electrical characteristics section 75
Change Description (Rev. 1.6 to 1.7)
SPR2 bit reinstated in SPI chapter 49 to 61
Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of useof such information nor for any infringement ofpatents orotherrights ofthird parties which may result from itsuse. No license isgranted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of STMicroelectronics.
The ST logo is a registered trademark of STMicroelectronics
Purchase of I
Australia - Brazil - China - Finland - France - Germany - Hong Kong -India - Italy - Japan - Malaysia - Malta - Morocco - Singapore - Spain
2
C Components by STMicroelectronics conveys a license under the Philips I2C Patent. Rights to use these components in an
2
I
C system is granted provided that the system conforms to the I2C Standard Specification as defined by Philips.
1999 STMicroelectronics - All Rights Reserved.
STMicroelectronics Group of Companies
Sweden - Switzerland - United Kingdom - U.S.A.
http://www.st.com
84/84
Loading...