– 8 or 4 high sink outputs
– 8 or 6 analog alternate inputs
– 13 alternate functions
– EMI filtering
■ Software or Hardware Watchdog (WDG)
■ Two 16-bit Timers, each featuring:
– 2 Input Captures
– 2 Output Compares
– External Clock input (on Timer A)
1)
1)
PSDIP56
– PWM and Pulse Generator modes
■ Synchronous Serial Peripheral Interface (SPI)
■ Asynchronous Serial Communications Interface
(SCI)
■ 8-bit ADC with 8 channels
■ 8-bit Data Manipulation
■ 63 basic Instructions and 17 main Addressing
2)
TQFP64
Modes
■ 8 x8 Unsigned Multiply Instruction
■ True BitManipulation
■ Complete Development Support on DOS/
WINDOWSTMReal-Time Emulator
■ Full Software Package on DOS/WINDOWS
TM
(C-Compiler, Cross-Assembler, Debugger)
(See ordering information at the end of datasheet)
Notes:
1. One only on Timer A.
2. Six channels only for ST72T311J.
Device Summary
FeaturesST72T311J2ST72T311J4ST72T311N2ST72T311N4
Program Memory - bytes8K16K8K16K
RAM (stack) - bytes384 (256)512 (256)384 (256)512 (256)
PeripheralsWatchdog, Timers, SPI, SCI, ADC and optional Low Voltage Detector Reset
Operating Supply3 to 5.5 V
CPU Frequency8MHz max (16MHz oscillator) - 4MHz max over 85°C
Temperature Range- 40°C to + 125°C
PackageTQFP44 -SDIP42TQFP64 -SDIP56
Note: The ROM versions are supportedby the ST72314 family.
The ST72T311 HCMOS Microcontroller Unit
(MCU) is a member of the ST7 family.The device
is based on an industry-standard 8-bit core and
features an enhanced instruction set. The device
is normally operated at a 16 MHz oscillator frequency. Under software control, the ST72T311
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 ST72T311 features
true bit manipulation, 8x8 unsigned multiplication
and indirect addressing modeson the whole memory. The device includes a low consumption and
Figure 1. ST72T311 Block Diagram
Internal
OSCIN
OSCOUT
RESET
PF0 -> PF2,4,6,7
OSC
CONTROL
AND LVD
8-BIT CORE
ALU
PROGRAM
MEMORY
(8 - 16K Bytes)
RAM
(384 - 512 Bytes)
PORT F
TIMER A
CLOCK
fast start on-chip oscillator, CPU, program memory(OTP/EPROMversions),RAM,44
(ST72T311N) or 32 (ST72T311J) I/O lines, a Low
Voltage Detector (LVD) and the following on-chip
peripherals: Analog-to-Digital converter (ADC)
with 8 (ST72T311N)or 6(ST72T311J) multiplexed
analog inputs, industry standard synchronous SPI
and asynchronous SCI serial interfaces, digital
Watchdog, two independent 16-bit Timers, one
featuring an External Clock Input, andboth featuring Pulse Generatorcapabilities, 2 Input Captures
and 2 Output Compares (only1 Input Capture and
1 Output Compare on Timer A).
PA0 -> PA7
(8 bits for ST72T311N)
(5 bits for ST72T311J)
PB0 -> PB7
(8 bits for ST72T311N)
(5 bits for ST72T311J)
PC0 -> PC7
(8 bits)
PD0 -> PD7
(8 bits for ST72T311N)
(6 bits for ST72T311J)
91PB4I/OPort B4External Interrupt: EI3
102PB5I/OPort B5External Interrupt: EI3
113PB6I/OPort B6External Interrupt: EI3
124PB7I/OPort B7External Interrupt: EI3
135PD0/AIN0I/OPort D0 or ADC Analog Input 0
146PD1/AIN1I/OPort D1 or ADC Analog Input 1
157PD2/AIN2I/OPort D2 or ADC Analog Input 2
168PD3/AIN3I/OPort D3 or ADC Analog Input 3
179PD4/AIN4I/OPort D4 or ADC Analog Input 4
1810PD5/AIN5I/OPort D5 or ADC Analog Input 5
1911PD6/AIN6I/OPort D6 or ADC Analog Input 6
2012PD7/AIN7I/OPort D7 or ADC Analog Input 7
2113V
2214V
23V
24V
DDA
SSA
DD_3
SS_3
SPower Supply for analog peripheral (ADC)
SGround for analog peripheral (ADC)
SMain power supply
SGround
2515PF0/CLKOUTI/OPort F0 or CPU Clock OutputExternal Interrupt: EI1
2616PF1I/OPort F1External Interrupt: EI1
2717PF2I/OPort F2External Interrupt: EI1
28NCNot Connected
2918PF4/OCMP1_AI/OPort F4 or Timer A Output Compare 1
30NCNot Connected
3119PF6/ICAP1_AI/OPort F6 or Timer AInput Capture 1
3220PF7/EXTCLK_AI/OPort F7 or External Clock on Timer A
3321V
3422V
DD_0
SS_0
SMain power supply
SGround
3523PC0/OCMP2_BI/OPort C0 or Timer B Output Compare 2
3624PC1/OCMP1_BI/OPort C1 or Timer B Output Compare 1
3725PC2/ICAP2_BI/OPort C2 or Timer B Input Capture 2
3826PC3/ICAP1_BI/OPort C3 or Timer B Input Capture 1
3927PC4/MISOI/OPort C4 or SPI Master In/ Slave Out Data
4028PC5/MOSII/OPort C5 or SPI Master Out/ Slave In Data
4129PC6/SCKI/OPort C6 or SPI Serial Clock
4230PC7/SSI/OPort C7 or SPI Slave Select
4331PA0I/OPort A0External Interrupt: EI0
4432PA1I/OPort A1External Interrupt: EI0
Test mode pin. In the EPROM programming
mode, thispin acts as the programming voltage
input V
PP.
This pin must be tied
low in user mode
5442RESETI/OBidirectional. Active low. Top priority non maskable interrupt.
55NCNot Connected
56NCNot Connected
5743V
SS_2
5844OSCOUTO
5945OSCINI
6046V
DD_2
SGround
Input/Output Oscillator pin. These pins connect a parallel-resonant
crystal, or an external source to theon-chip oscillator.
SMain power supply
6147PE0/TDOI/OPort E1 or SCI Transmit Data Out
6248PE1/RDII/OPort E1 or SCI Receive Data In
63NCNot Connected
64NCNot Connected
Note 1:VPPon EPROM/OTP only.
Table 2. ST72T311Jx Pin Description
Pin n°
QFP44
Pin n°
SDIP42
Pin NameTypeDescriptionRemarks
138PE1/RDII/OPort E1 or SCI Receive Data In
239PB0I/OPort B0External Interrupt: EI2
340PB1I/OPort B1External Interrupt: EI2
441PB2I/OPort B2External Interrupt: EI2
542PB3I/OPort B3External Interrupt: EI2
61PB4I/OPort B4External Interrupt: EI3
72PD0/AIN0I/OPort D0or ADC Analog Input 0
83PD1/AIN1I/OPort D1or ADC Analog Input 1
94PD2/AIN2I/OPort D2or ADC Analog Input 2
105PD3/AIN3I/OPort D3 or ADC Analog Input 3
116PD4/AIN4I/OPort D4 or ADC Analog Input 4
127PD5/AIN5I/OPort D5 or ADC Analog Input 5
138V
149V
DDA
SSA
SPower Supply for analog peripheral (ADC)
SGround for analog peripheral (ADC)
1510PF0/CLKOUTI/OPort F0 or CPU Clock OutputExternal Interrupt: EI1
1611PF1I/OPort F1External Interrupt: EI1
1712PF2I/OPort F2External Interrupt: EI1
1813PF4/OCMP1_AI/OPort F4 or Timer A Output Compare 1
7/100
7
ST72E311 ST72T311
Pin n°
QFP44
Pin n°
SDIP42
Pin NameTypeDescriptionRemarks
1914PF6/ICAP1_AI/OPort F6 or Timer A Input Capture 1
2015PF7/EXTCLK_AI/OPort F7 or External Clock on Timer A
21V
22V
DD_0
SS_0
SMain power supply
SGround
2316PC0/OCMP2_BI/OPort C0or Timer B Output Compare 2
2417PC1/OCMP1_BI/OPort C1or Timer B Output Compare 1
2518PC2/ICAP2_BI/OPort C2or Timer B Input Capture 2
2619PC3/ICAP1_BI/OPort C3or Timer B Input Capture 1
2720PC4/MISOI/OPort C4or SPI Master In / Slave Out Data
2821PC5/MOSII/OPort C5or SPI Master Out / Slave In Data
2922PC6/SCKI/OPort C6 or SPI Serial Clock
3023PC7/SSI/OPort C7or SPI Slave Select
3124PA3I/OPort A3External Interrupt: EI0
3225V
3326V
Test mode pin. In the EPROM programming
mode, this pin acts as the programming
voltage input V
PP.
This pin must be tied
low in user mode
3932RESETI/OBidirectional. Active low. Top priority non maskable interrupt.
4033V
SS_2
4134OSCOUTO
4235OSCINI
4336V
DD_2
SGround
Input/Output Oscillator pin. These pins connect a parallel-resonant
crystal, or an external source to the on-chip oscillator.
SMain power supply
4437PE0/TDOI/OPort E0 or SCI Transmit Data Out
Note 1:VPPon EPROM/OTP only.
8/100
8
1.3 EXTERNAL CONNECTIONS
ST72E311 ST72T311
The following figure shows the recommended external connections for the device.
The VPPpin is only used for programming OTP
and EPROM devices and must be tied 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 6. Recommended External Connections
V
DD
Optional if Low Voltage
Detector (LVD) isused
EXTERNAL RESET CIRCUIT
10nF
+
See
A/D Converter
Section
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
V
DDA
V
SSA
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
SCI Status Register
SCI Data Register
SCI Baud Rate Register
SCI Control Register 1
SCI Control Register 2
SCI Extended Receive Prescaler Register
Reserved
SCI Extended Transmit Prescaler Register
Reserved Area (24 bytes)
ADC Data Register
ADC Control/Status Register
Reserved Area (14 bytes)
00h
00h
xxh
xxh
xxh
80h
00h
FFh
FCh
FFh
FCh
xxh
xxh
80h
00h
C0h
xxh
00x----xb
xxh
00h
00h
---
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
R/W
R/W
R/W
R/W
Reserved
R/W
Read Only
R/W
Notes:
1. The bits corresponding to unavailable pins are forcedto 1by hardware, this affects the reset status value.
2. External pin not available.
3. Not used in versions without Low Voltage Detector Reset.
Remarks
2)
2)
2)
2)
12/100
12
1.5 OPTION BYTE
ST72E311 ST72T311
The user has the option to select software watchdog or hardware watchdog (see description in the
Watchdog chapter). When programming EPROM
or OTP devices, this option is selected in a menu
by the user of the EPROM programmer before
burning the EPROM/OTP. The Option Byte is located in a non-user map. No address has to be
specified. TheOption Byte is atFFh after UVerasure and must be properly programmed to set desired options.
OPTBYTE
70
----b3b2-WDG
Bit 7:4 = Not used
Bit 3 = Reserved, must be cleared.
Bit 2 = Reserved, must be set onST72T311N devices and mustbe cleared onST72T311J devices.
Bit 1 = Not used
Bit 0 = WDG
Watchdog disable
0: The Watchdog is enabled after reset (Hardware
Watchdog).
1: The Watchdog is not enabled after reset (Soft-
ware Watchdog).
13
13/100
ST72E311 ST72T311
2 CENTRAL PROCESSING UNIT
2.1 INTRODUCTION
This CPU hasa full 8-bit architecture and contains
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 8 are not
present in thememory mappingand are accessed
by specificinstructions.
Figure 8. 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 and to manipulate
data.
Index Registers (Xand Y)
In indexedaddressing modes, these 8-bitregisters
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 to and popped from
the stack).
Program Counter (PC)
The program counter is a 16-bit register containing
the address of the next instruction to be executed
by the CPU. It is made of two 8-bit registers PCL
(Program CounterLow which is 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
14/100
PCH
RESET VALUE =
7
70
1C11HI NZ
1X11X1XX
870
PCL
14
0
PROGRAM COUNTER
CONDITION CODE REGISTER
STACK POINTER
X = Undefined Value
ST72E311 ST72T311
CENTRAL PROCESSING UNIT (Cont’d)
CONDITION CODE REGISTER (CC)
Read/Write
Reset Value: 111x1xxx
70
ter it and reset by the IRET instruction at the end of
the interrupt routine. If the I bit is cleared by software inthe interrupt routine, pending interrupts are
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 instruction just executed. Thisregister
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 by hardware when a carry occurs between bits 3 and 4 of the ALU during an ADD or
ADC instruction.It is reset by hardware during the
same instructions.
0: No half carry has occurred.
1: A half carry has occurred.
This bit is tested using the JRH or JRNH instruction. The H bit is useful in BCD arithmetic subroutines.
Bit 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 by the 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 youen-
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:The result of the lastoperation is positive or null.
1: The result of the last operation is negative
(i.e. the most significant bit is a logic 1).
This bit isaccessed bythe 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 RCFinstructions
and tested by theJRC and JRNC instructions. It is
also affected by the “bit testand branch”, shift and
rotate instructions.
th
15
15/100
ST72E311 ST72T311
CENTRAL PROCESSING UNIT (Cont’d)
Stack Pointer (SP)
Read/Write
Reset Value: 01FFh
158
00000001
70
SP7SP6SP5SP4SP3SP2SP1SP0
The Stack Pointer is a 16-bit register which is always pointingto the next freelocation in the stack.
It isthen decremented after data has been pushed
onto the stack and incremented before data is
popped from the stack (see Figure 9).
Since the stack is 256 bytes deep, the 8th 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 SP7 to SP0 bits are set) which is the
stack higheraddress.
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 to the stack upperlimit, without indicating the stack overflow. The previously
stored information is then overwritten and therefore lost.The stack also wrapsin case of anunderflow.
The stack is used to save the return address during a subroutine call and the CPU context during
an interrupt.The user may alsodirectly 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 9.
– Whenan interrupt is received, the SP is decre-
mented and the context is pushed on the stack.
– On return from interrupt, the SP is incremented
and thecontext ispopped from the stack.
A subroutine call occupies twolocations and aninterrupt five locations in the stack area.
The MCU accepts either a crystal or ceramic resonator, or an external clock signal todrive the internal oscillator. The internal clock (f
from the external oscillator frequency (f
) is derived
CPU
OSC).
The
external Oscillator clock is first divided by 2, and
an additional divisionfactor of 2, 4, 8, or 16 canbe
applied, in Slow Mode, to reduce the frequency of
the f
; this clock signal is also routed to the on-
CPU
chip peripherals. TheCPU clock signal consists of
a squarewave with a duty cycle of50%.
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 11 is recommended when
using a crystal, and Table 5 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.
3.1.2 External Clock
An externalclock maybe applied tothe OSCIN input with the OSCOUT pin not connected, as
shown onFigure 10.
Figure 10. External Clock Source Connections
OSCINOSCOUT
NC
EXTERNAL
CLOCK
Figure 11. Crystal/CeramicResonator
OSCINOSCOUT
C
OSCIN
C
OSCOUT
Table 5 Recommended Values for 16 MHz
Crystal Resonator (C0< 7pF)
R
SMAX
R
SMAX
C
OSCIN
C
OSCOUT
: Parasitic series resistance of the quartz
40 Ω60 Ω150 Ω
56pF47pF22pF
56pF47pF22pF
crystal (upperlimit).
C0: Parasitic shunt capacitance of the quartz crys-
tal (upper limit 7pF).
C
OSCOUT,COSCIN
: Maximum total capacitance on
pins OSCIN and OSCOUT (the valueincludes the
external capacitance tied to the pin plus the parasitic capacitance of the board and of the device).
Figure 12. Clock Prescaler Block Diagram
C
OSCIN
OSCIN
OSCOUT
%2%2,4,8, 16
C
OSCOUT
f
CPU
to CPU and
Peripherals
17
17/100
ST72E311 ST72T311
3.2 RESET
3.2.1 Introduction
There are four sources of Reset:
– RESET pin (externalsource)
– Power-On Reset (Internal source)
– WATCHDOG (Internal Source)
– Low Voltage Detection Reset (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
RESET
to reset
the whole application.
3.2.3 ResetOperation
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 ofat least t
PULSE
in orderto
Figure 13. Reset Block Diagram
be recognised. This detection is asynchronous
and therefore the MCUcan 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 the MCU can operate correctly before the user program is run. Following 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 has taken 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 Figure 6.
RESET
OSCILLATOR
SIGNAL
V
DD
R
ON
TO ST7
RESET
INTERNAL
RESET
COUNTER
POWER-ON RESET
WATCHDOG RESET
LOW VOLTAGE DETECTOR RESET
18/100
18
RESET (Cont’d)
3.2.4 LowVoltage Detector Reset
The on-chip Low Voltage Detector (LVD) generates a static reset when the supply voltage is be-
cases, it is recommended to use devices without
the LVD Reset option and to rely on the watchdog
function to detect application runaway conditions.
low a reference value. The LVD functions both
during power-on as well as when the power supply
drops (brown-out). The reference value for a volt-
Figure14.LowVoltage DetectorResetFunction
age drop is lower than the referencevalue for power-on in order to avoid a parasitic reset when the
V
MCU starts running and sinks current on the supply (hysteresis).
DD
DETECTOR RESET
The LVD Reset circuitry generates a reset when
VDDis below:
V
LVDUP
V
LVDDOWN
Provided the minimun VDDvalue (guaranteed for
the oscillator frequency) is above V
MCU can only be in two modes:
- underfull software control or
when VDDis rising
when VDDis falling
LVDDOWN
, the
Figure 15. Low Voltage Detector Reset Signal
V
LVDUP
- instatic safe reset
In this condition, secure operation is always en-
V
DD
sured for the application without the need for external reset hardware.
RESET
During a Low Voltage Detector Reset, the RESET
pin is held low, thus permitting the MCU to reset
other devices.
In noisy environments, the power supplymay drop
for short periods and cause the Low Voltage De-
Note: See electrical characteristics for values of
V
LVDUP
and V
tector to generate a Reset too frequently. In such
Figure 16. Temporization timing diagram after an internal Reset
LOW VOLTAGE
FROM
WATCHDOG
RESET
LVDDOWN
ST72E311 ST72T311
RESET
V
LVDDOWN
V
DD
Addresses
V
LVDUP
Temporization (4096CPU clock cycles)
$FFFE
19/100
19
ST72E311 ST72T311
3.3 INTERRUPTS
The ST7 coremay be interrupted by one oftwo different methods: maskable hardware interrupts as
listed in the Interrupt Mapping Table and a nonmaskable software interrupt (TRAP). The Interrupt
processing flowchartis shown in Figure 17.
The maskable interrupts mustbe enabled clearing
the I bitin order tobe 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 registers are saved onto
the stack.
– The I bit of theCC register is set to prevent addi-
tional interrupts.
– ThePC is thenloaded withthe interrupt 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 (see the 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 17.
Interrupts and Low power mode
All interrupts allowthe processor to leave the Wait
low power mode. Only external and specific mentioned interrupts allow the processor to leave the
Halt low power mode (refer to 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 the edge/
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.
– The correspondingenable bit is set in the control
register.
If any of these two conditions is false, the interrupt
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 writeof an associated
register.
Note: the clearing sequence resets the internal
latch. A pending interrupt (i.e. waiting for being enabled) will therefore be lost if the clear sequence is
executed.
NOT USEDFFE4h-FFE5h
NOT USEDFFE2h-FFE3h
NOT USEDFFE0h-FFE1h
Register
Label
SPISR
TASR
TBSR
SCISR
Flag
SPIF
ICF1_A
ICF1_B
TDRE
Exit
from
HALT
yes
no
Vector
Address
FFF6h-FFF7h
FFECh-FFEDh
FFEAh-FFEBh
FFE8h-FFE9h
FFE6h-FFE7h
Priority
Order
Highest
Priority
Lowest
Priority
22/100
22
3.4 POWER SAVING MODES
3.4.1 Introduction
There are threePower Savingmodes. SlowMode
is selected by setting the relevant bits in the Miscellaneous register. Wait and Halt modes may be
entered usingthe WFI and HALT instructions.
ST72E311 ST72T311
Figure 18. 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, and enables 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 Waitmode until a Reset or
an Interrupt occurs, causing it to wake up.
Refer to Figure 18 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
23/100
23
ST72E311 ST72T311
POWER SAVINGMODES (Cont’d)
3.4.4 Halt Mode
The Halt mode is the MCU lowest power consumption mode. The Halt mode is entered by executing theHALT instruction. The internal oscillator
is then turned off, causing all internal 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 systemis enabled,a
watchdog reset is generatedthus resetting the entire MCU.
When entering Halt mode, the Ibit in the CC Register is clearedso as to enable External Interrupts.
If an interrupt occurs, the CPU becomes active.
The MCU canexit the Halt mode upon receptionof
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 time is 4096 CPU clock
cycles.
After the start up delay, the CPU continuesoperation byservicing the interrupt which wakes itup or
by fetching the reset vector if a resetwakes it up.
Figure 19. 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
24/100
24
3.5 MISCELLANEOUS REGISTER
ST72E311 ST72T311
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 and EI1 causes the
external interrupt according to Table 8.
Table 8. EI0 and EI1 External Interrupt Polarity
70
PEI3 PEI2 MCO PEI1 PEI0 PSM1 PSM0 SMS
Bit 7:6 = PEI[3:2]
Polarity Options
External Interrupt EI3 and EI2
.
These bits are set and cleared by software. They
determine which event on EI2 and EI3 causes the
Options
MODEPEI1PEI0
Falling edge and low level
(Reset state)
Falling edge only10
Rising edge only01
Rising and falling edge11
external interrupt according to Table 7.
Table 7. EI2 and EI3 External Interrupt Polarity
Options
Note: Any modification of oneof these two bits re-
sets the interrupt request related to this interrupt
vector.
MODEPEI3PEI2
Falling edge and low level
(Reset state)
Falling edge only10
Rising edge only01
Rising and falling edge11
Note: Any modification of one of these two bits resets the interrupt request related to this interrupt
vector.
Bit 5 = MCO
Main Clock Out
This bit isset and cleared by software. Whenset, it
enables the output of the Internal Clock on the
00
Bit 2:1 = PSM[1:0]
These bits are set and cleared by software. They determine the CPU clock
when the SMS bit is set according to the
following table.
Table 9. f
Value in Slow Mode
CPU
f
Value
CPU
f
OSC
f
OSC
f
OSC
f
OSC
Prescaler forSlow Mode
/400
/1601
/810
/3211
PPF0 I/O port.
0 -PF0 is a general purpose I/O port.
1 -MCO alternate function (f
is output on PF0
CPU
pin).
Bit 0 = SMS
Slow Mode Select
This bit is set and cleared by software.
0: Normal Mode - f
CPU=fOSC
/2
(Reset state)
1: Slow Mode -the f
valueis determined by the
CPU
PSM[1:0] bits.
00
PSM1PSM0
25
25/100
ST72E311 ST72T311
4 ON-CHIP PERIPHERALS
4.1 I/O PORTS
4.1.1 Introduction
The I/O ports offer different functional modes:
– transferof datathrough digitalinputs and 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 be programmed using thecorre-
sponding register bits in DDR and OR registers: bit
X corresponding topin Xof the port. The samecorrespondence is used for the DR register.
The following description takes into account the
OR register, for specific ports whichdo notprovide
this register refer to the I/O Port Implementation
Section 4.1.3. The generic I/O block diagram is
shown onFigure 21.
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 be selected 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 theCPU. The interrupt 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 configuredin output mode by setting 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 the peripheral).
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 beconfigured asan input
(DDR = 0).
Warning
vated as long as the pin isconfigured as input with
interrupt, in order to avoid generating spurious interrupts.
: The alternate function must not be acti-
26/100
26
I/O PORTS (Cont’d)
4.1.2.4 Analog Alternate Function
When the pin is used as an 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 and OR registers
and specific feature of the I/O port such as ADCInput (see Figure 21) 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 are illustrated in Figure 20. 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 20. Recommended I/O State Transition Diagram
ST72E311 ST72T311
INPUT
with interrupt
INPUT
no interrupt
OUTPUT
OUTPUT
push-pullopen-drain
27
27/100
ST72E311 ST72T311
I/O PORTS (Cont’d)
Figure 21. 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 TABLE BELOW)
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 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.
28/100
DD
Diode
28
I/O PORTS (Cont’d)
Table 11. Port Configuration
ST72E311 ST72T311
PortPin name
PA0:PA2
Port A
PA3floating*pull-up with interruptopen-drainpush-pull
1)
Input (DDR = 0)Output (DDR = 1)
OR= 0OR= 1OR = 0OR=1
floating*pull-up with interruptopen-drainpush-pull
PA4:PA7floating*true open drain, high sink capability
PB0:PB4floating*pull-up with interruptopen-drainpush-pull
Port B
PB5:PB7
1)
floating*pull-up with interruptopen-drainpush-pull
Port CPC0:PC7floating*pull-upopen-drainpush-pull
PD0:PD5floating*pull-upopen-drainpush-pull
Port D
PD6:PD7
1)
floating*pull-upopen-drainpush-pull
PE0:PE1floating*pull-upopen-drainpush-pull
Port E
PE4:PE7
1)
floating*
2)
true open drain,
high sink capability
PF0:PF2floating*pull-up with interruptopen-drainpush-pull
Port F
PF4, PF6,PF7floating*pull-upopen-drainpush-pull
Notes:
1. ST72T311N only
2. For OTP/EPROM version, when OR=0: floating & when OR=1: reserved
3. For OTP/EPROM version, when OR=0: open-drain, high sinkcapability & when OR=1: reserved
3)
* Reset state (The bits corresponding to unavailable pins are forced to 1 by hardware, this affects the reset status value).
Warning: Allbits of the DDR register whichcorrespond to unconnected I/Os must be left attheir reset value. They must not be modified by the user otherwise a spurious interruptmay be generated.
29/100
29
ST72E311 ST72T311
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)
Port D Data Register (PDDR)
Port E Data Register (PEDR)
Port F Data Register (PFDR)
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 (PBOR)
Port D Option Register (PBOR)
Port E OptionRegister (PBOR)
Port F Option Register (PFOR)
Read/Write
Reset Value: see Register Memory Map Table 4
70
D7D6D5D4D3D2D1D0
Bit 7:0 = D7-D0
Data Register 8 bits.
The DR register has a specific behaviour according to the selected input/output configuration. Writing 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 value applied to the I/O pin (pin configured as input).
70
O7O6O5O4O3O2O1O0
Bit 7:0 = O7-O0
Option Register8 bits.
The OR register allow to distinguish in input mode
if the interrupt capability or the floating configuration is selected.
In output mode it select push-pull or open-drain
capability.
Each bit is set and cleared by software.
Input mode:
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)
0: floating input
1: input pull-up with interrupt
Output mode:
0: open-drain configuration
1: push-pull configuration
Port D Data Direction Register (PDDDR)
Port E Data Direction Register (PEDDR)
Port F Data Direction Register (PFDDR)
Read/Write
Reset Value: 0000 0000 (00h) (input mode)
70
DD7DD6DD5DD4DD3DD2DD1DD0
Bit 7:0 = DD7-DD0
Data Direction Register 8 bits.
The DDR register gives the input/output direction
configuration of the pins. Each bits is set and
cleared by software.
0: Input mode
1: Output mode
30/100
30
Loading...
+ 70 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.