– 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
FeaturesST72101G1ST72101G2ST72213G1ST72212G2
Program Memory- bytes4K8K4K8K
RAM (stack) - bytes256 (64)
16-bit Timersoneoneonetwo
ADCnonoyesyes
Other PeripheralsWatchdog, SPI
Operating Supply3 to 5.5 V
CPU Frequency8MHz max (16MHz oscillator) - 4MHz max over 85°C
Temperature Range- 40°C to + 125°C
PackageSO28 - SDIP32
The ST72101, ST72213 and ST72212 HCMOS
Microcontroller Units are members of the ST7
family. These devices are based on an industrystandard 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-toDigital 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
11RESETI/O Bidirectional. Active low. Top priority non maskable interrupt.
22OSCINI
33OSCOUTO
Input/Output Oscillator pin. These pins connect a parallel-resonant
crystal, or an external source to the on-chip oscillator.
44PB7/SSI/O Port B7 or SPI Slave Select (active low)External Interrupt: EI1
55PB6/SCKI/O Port B6 or SPI Serial ClockExternal Interrupt: EI1
66PB5/MISOI/O Port B5 or SPI Master In/ Slave Out DataExternal Interrupt: EI1
77PB4/MOSII/O Port B4 or SPI Master Out / Slave In DataExternal Interrupt: EI1
8NCNot Connected
9NCNot Connected
108PB3/OCMP2_AI/O Port B3 or TimerA Output Compare 2External Interrupt: EI1
119PB2/ICAP2_AI/O Port B2 or TimerA Input Capture 2External Interrupt: EI1
1210PB1/OCMP1_AI/O Port B1 or TimerA Output Compare 1External Interrupt: EI1
1311PB0/ICAP1_AI/O Port B0 or TimerA Input Capture 1External Interrupt: EI1
1412PC5/EXTCLK_A/AIN5 I/O PortC5orTimerA InputClockorADCAnalog Input5 External Interrupt: EI1
1513PC4/OCMP2_B/AIN4I/O
1614PC3 /IC A P2 _ B /AIN 3I/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
1715PC2/CLKOUT/AIN2I/O
Analog Input 2. Clockout is driven by Bit 5 of the
External Interrupt: EI1
miscellaneous register.
1816PC1/OCMP1_B/AIN1I/O
1917PC0 /IC A P1 _ B /AIN 0I/O
PortC1orTimerB OutputCompare1orADCAnalog
Input 1
Port C0 orTimerB InputCapture 1 orADC Analog
Input 0
External Interrupt: EI1
External Interrupt: EI1
2018PA7I/O Port A7, High SinkExternal Interrupt: EI0
2119PA6I/O Port A6, High SinkExternal Interrupt: EI0
2220PA5I/O Port A5, High SinkExternal Interrupt: EI0
2321PA4I/O Port A4, High SinkExternal Interrupt: EI0
24NCNot Connected
25NCNot Connected
2622PA3I/O Port A3, High SinkExternal Interrupt: EI0
2723PA2I/O Port A2, High SinkExternal Interrupt: EI0
2824PA1I/O Port A1, High SinkExternal Interrupt: EI0
2925PA0I/O Port A0, High SinkExternal Interrupt: EI0
3026TEST/V
3127V
3228V
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
SGround
SMain power supply
PP.
6/84
6
Table 2. ST72213 Pin Configuration
ST72101/ST72212/ST72213
Pin n°
SDIP32
Pin n°
SO28
Pin NameTypeDescriptionRemarks
11RESETI/O
22OSCINI
33OSCOUTO
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.
44PB7/SSI/O Port B7 orSPI Slave Select (active low)External Interrupt: EI1
55PB6/SCKI/O Port B6 orSPI Serial ClockExternal Interrupt: EI1
66PB5/MISOI/O Port B5 orSPI Master In/ Slave Out DataExternal Interrupt: EI1
77PB4/MOSII/O Port B4 orSPI Master Out / Slave In DataExternal Interrupt: EI1
8NCNot Connected
9NCNot Connected
108PB3/OCMP2_AI/O Port B3 or TimerA Output Compare 2External Interrupt: EI1
119PB2/ICAP2_AI/O Port B2 orTimerA Input Capture 2External Interrupt: EI1
1210PB1/OCMP1_AI/O Port B1 or TimerA Output Compare 1External Interrupt: EI1
1311PB0/ICAP1_AI/O Port B0 orTimerA Input Capture 1External Interrupt: EI1
1412PC5/EXTCLK_A/AIN5I/O
Port C5 orTimerA Input Clock or ADC Analog
Input 5
External Interrupt: EI1
1513PC4/AIN4I/O Port C4 or ADC Analog Input 4External Interrupt: EI1
1614PC3/AIN3I/O Port C3 or ADC Analog Input 3External Interrupt: EI1
Port C2 orInternal Clock Frequency Output or
1715PC2/CLKOUT/AIN2I/O
ADC Analog Input 2. Clockout is driven by Bit 5
External Interrupt: EI1
of the miscellaneous register.
1816PC1/AIN1I/O Port C1 or ADC Analog Input 1External Interrupt: EI1
1917PC0/AIN0I/O Port C0 or ADC Analog Input 0External Interrupt: EI1
2018PA7I/O Port A7, High SinkExternal Interrupt: EI0
2119PA6I/O Port A6, High SinkExternal Interrupt: EI0
2220PA5I/O Port A5, High SinkExternal Interrupt: EI0
2321PA4I/O Port A4, High SinkExternal Interrupt: EI0
24NCNot Connected
25NCNot Connected
2622PA3I/O Port A3, High SinkExternal Interrupt: EI0
2723PA2I/O Port A2, High SinkExternal Interrupt: EI0
2824PA1I/O Port A1, High SinkExternal Interrupt: EI0
2925PA0I/O Port A0, High SinkExternal Interrupt: EI0
3026TEST/V
3127V
3228V
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
SGround
SMain power supply
PP.
7/84
7
ST72101/ST72212/ST72213
Table 3. ST72101 Pin Configuration
Pin n°
SDIP32
Pinn°
SO28
Pin NameTypeDescriptionRemarks
11RESETI/O Bidirectional. Active low. Top priority non maskable interrupt.
22OSCINI
33OSCOUTO
Input/Output Oscillator pin. These pins connect a parallel-resonant crystal, or
an external source to the on-chip oscillator.
44PB7/SSI/O Port B7 orSPI Slave Select (active low)External Interrupt: EI1
55PB6/SCKI/O Port B6 orSPI Serial ClockExternal Interrupt: EI1
66PB5/MISOI/O Port B5 orSPI Master In/ Slave Out DataExternal Interrupt: EI1
77PB4/MOSII/O Port B4 orSPI Master Out / Slave In DataExternal Interrupt: EI1
8NCNot Connected
9NCNot Connected
108PB3/OCMP2_AI/O Port B3 orTimerA Output Compare 2External Interrupt: EI1
119PB2/ICAP2_AI/O Port B2 orTimerA Input Capture 2External Interrupt: EI1
1210PB1/OCMP1_AI/O Port B1 orTimerA Output Compare 1External Interrupt: EI1
1311PB0/ICAP1_AI/O Port B0 orTimerA Input Capture 1External Interrupt: EI1
1412PC5/EXTCLK_A I/O Port C5 or TimerA Input ClockExternal Interrupt: EI1
1513PC4I/O Port C4External Interrupt: EI1
1614PC3I/O Port C3External Interrupt: EI1
1715PC2/CLKOUTI/O
Port C2 or Internal Clock Frequency Output.Clockout
is driven by MCO bit of the miscellaneous register.
External Interrupt: EI1
1816PC1I/O Port C1External Interrupt: EI1
1917PC0I/O Port C0External Interrupt: EI1
2018PA7I/O Port A7, High SinkExternal Interrupt: EI0
2119PA6I/O Port A6, High SinkExternal Interrupt: EI0
2220PA5I/O Port A5, High SinkExternal Interrupt: EI0
2321PA4I/O Port A4, High SinkExternal Interrupt: EI0
24NCNot Connected
25NCNot Connected
2622PA3I/O Port A3, High SinkExternal Interrupt: EI0
2723PA2I/O Port A2, High SinkExternal Interrupt: EI0
2824PA1I/O Port A1, High SinkExternal Interrupt: EI0
2925PA0I/O Port A0, High SinkExternal Interrupt: EI0
3026TEST/V
3127V
3228V
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.
SGround
SMain power supply
8/84
8
1.3 EXTERNAL CONNECTIONS
ST72101/ST72212/ST72213
The following figure shows the recommended external 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 performance/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 unnecessary 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
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 register 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 instruction (PRE) to indicate that the following instruction refers to the Y register.)
The Y register is notaffected by theinterrupt automatic 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
158
RESET VALUE= RESET VECTOR @ FFFEh-FFFFh
15
RESET VALUE = STACKHIGHER ADDRESS
PCH
RESET VALUE =
7
70
1C11HINZ
1X11X1XX
870
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 software inthe interrupt routine, pending interruptsare
serviced regardless of the priority levelof the current interrupt routine.
111HINZC
The 8-bit Condition Code register contains the interrupt mask and four flags representative of the
result of the instructionjust executed. This register
can also be handled by the PUSH and POP instructions.
These bits can be individually tested and/or controlled by specific instructions.
Bit 4 = H
Half carry
.
This bit isset byhardware when a carry occurs between 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 instruction. The H bit is useful in BCD arithmetic subroutines.
Bit 3 = I
Interrupt mask
.
This bit is set by hardware when entering in interrupt 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 instructions andis tested bythe JRM and JRNM instructions.
Note: Interrupts requested while I is set are
latched and can be processed when I is cleared.
By default an interrupt routine is not 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 representative 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 instructions.
Bit 1 = Z
Zero
.
This bit is set and clearedby hardware. Thisbit indicates 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 software. 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
158
00000001
70
01SP5SP4SP3SP2SP1SP0
The Stack Pointer is a 16-bit register which is always 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 significant bits are forced by hardware. Following an
MCU Reset, or after a Reset Stack Pointer instruction (RSP), the Stack Pointer contains its reset value (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 instruction.
Note: When the lower limit is exceeded, the Stack
Pointer wraps around tothe stackupper limit, without indicating the stack overflow. The previously
stored information is then overwritten and therefore lost.The stackalso wrapsin caseof anunderflow.
The stack is used to save the return address during a subroutine call and the CPU context during
an interrupt.Theuser may also directly manipulate
the stack by means of the PUSH and POP instructions. 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 aninterrupt five locations in the stack area.
The MCU accepts either a Crystal or Ceramicresonator, or an external clock signal to drive the internal 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 Miscellaneous 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 resonator 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 recommended 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 recommended when crystals outside the specified frequency ranges are to be used.
Figure 12. External Clock Source Connections
OSCINOSCOUT
NC
EXTERNAL
CLOCK
Figure 13. Crystal/CeramicResonator
OSCINOSCOUT
Table 6. Recommended Values for 16 MHz
Crystal Resonator (C0<7pF)
R
SMAX
C
OSCIN
C
OSCOUT
40 Ω60 Ω150 Ω
56pF47pF22pF
56pF47pF22pF
C0: parasitic shunt capacitance of the quartz crystal.
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 signal. The RESET pin may thus be used to ensure
VDDhas risen to a point where theMCU can operate 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 ensure that recovery hastaken place from the Reset
state.
In the high state, the RESET pin is connected internally 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 external 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 application (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 different methods: maskable hardware interrupts as
listed in the Interrupt Mapping Table and a nonmaskable 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 subsection).
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 addresses).
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 interrupted because the I bit is set by hardware entering in interrupt routine.
In the case several interrupts are simultaneously
pending, an hardware priority defines which one
will be serviced first (seethe Interrupt Mapping Table).
Non Maskable Software Interrupts
This interrupt is entered when the TRAP instruction 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 mentioned 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 occurred 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 interrupt vector, are configured as interrupts, their signals 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 interrupt, 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 enabled) will therefore be lost ifthe clear sequence is
executed.
There are threePower Saving modes. SlowMode
is selected by setting the relevant bits in the Miscellaneous 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 divided 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 consumption mode by stoppingthe CPU. Allperipherals 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 Interrupt or Reset occurs, whereupon the Program
Counter branches to the starting address of the Interrupt 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 interrupt 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 consumption mode. The Halt mode is entered byexecuting 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 entire MCU.
When entering Halt mode, the Ibit in the CC Register 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 Mapping 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 continuesoperation 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 interrupt 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 interrupt requestsand to output the internal clock.
These bits are set and cleared by software. They
determine which event on EI0 causes the external interrupt according to Table 9.
Table 9. EI0 External Interrupt Polarity Options
MODEPEI1PEI0
Falling edge and low level
(Reset state)
Falling edge only10
Rising edge only01
Rising and falling edge11
determine which event on EI1 causes the external interrupt according to Table 8.
Note: Any modification of oneof these two bits re-
Table 8. EI1 External Interrupt Polarity Options
MODEPEI3PEI2
Falling edge and low level
(Reset state)
Falling edge only10
Rising edge only01
Rising and falling edge11
00
Note: Any modification of one of these twobits resets 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 output.
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 correspondence 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 configured 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 Interrupt 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 dedicated group of I/O port pins (see Interrupts section). If several input pins are configured as inputs
to the same interrupt vector, their signals are logically ANDed before entering the edge/level detection 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 disabled.
4.1.2.3 Digital Alternate Function
When an on-chipperipheral is configured to use a
pin, the alternate function is automatically selected. 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 unexpected value atthe input of the alternate peripheral 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 interrupts.
: 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 multiplexer (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 analog pin.
Warning
: The analog input voltage level must be
4.1.3 I/O Port Implementation
The hardware implementation oneach I/O port depends on the settingsin theDDR andOR registers
and specific feature ofthe I/O portsuch as ADCInput (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 areillustrated in Figure 19. Other transitions are potentially 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 ModePull-upP-bufferV
Floating001
Pull-up101
Push-pull011
True Open Drainnot presentnot present
Open Drain (logic level)001
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
Loading...
+ 58 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.