8-bit low-power, full-speed USB MCU with 16-Kbyte Flash,
LQFP64 14x14
SO24
QFN24
768-byte RAM, smartcard interface and timer
Features
Memories
■
Up to 16 Kbytes of ROM or High Density Flash
(HDFlash) program memory with read/write
protection, HDFlash In-Circuit and In-Application
Programming. 100 write/erase cycles
guaranteed, data retention: 40 years at 55°C
■ Up to 768 bytes of RAM including up to 128
bytes stack and 256 bytes USB buffer
Clock, reset and supply management
■ Low voltage reset
■ 2 power saving modes: Halt and Wait modes
■ PLL for generating 48 MHz USB clock using a
4 MHz crystal
Interrupt management
■ Nested Interrupt controller
USB (Universal Serial Bus) interface
■ 256-byte buffer for full speed bulk, control and
interrupt transfer types compliant with USB
specification (version 2.0)
■ On-Chip 3.3V USB voltage regulator and
transceivers with software power-down
■ 7 USB endpoints:
– One 8-byte Bidirectional Control Endpoint
– One 64-byte In Endpoint,
– One 64-byte Out Endpoint
– Four 8-byte In Endpoints
35 or 4 I/O ports
■ Up to 4 LED outputs with software
programmable constant current (3 or 7 mA).
■ 2 General purpose I/Os programmable as
interrupts
■ Up to 8 line inputs programmable as interrupts
■ Up to 20 outputs
■ 1 line assigned by default as static input after
reset
ST7SCR1E4, ST7SCR1R4
Datasheet − production data
ISO7816-3 UART interface
■ 4 MHz clock generation
■ Synchronous/Asynchronous protocols
(T=0, T=1)
■ Automatic retry on parity error
■ Programmable baud rate from 372 clock
pulses up to 11.625 clock pulses (D=32/F=372)
■ Card Insertion/Removal Detection
Smartcard power supply
■ Selectable card V
■ Internal step-up converter for 5V supplied
Smartcards (with a current of up to 55mA)
using only two external components.
■ Programmable Smartcard Internal Voltage
Regulator (1.8V to 3.0V) with current overload
protection and 4 KV ESD protection (Human
Body Model) for all Smartcard Interface I/Os
One 8-bit timer
■ Time Base Unit (TBU) for generating periodic
interrupts.
Development tools
■ Full hardware/software development package
ECOPACK® packages
Table 1.Device summary
ReferencePart number
ST7SCR1R4ST7FSCR1T1, ST7SCR1T1
ST7SCR1E4
1.8V, 3V, and 5V
CC
ST7FSCR1M1, ST7SCR1M1,
ST7SCR1U1
July 2012Doc ID 8951 Rev 61/121
This is information on a product in full production.
The ST7SCR and ST7FSCR devices are members of the ST7 microcontroller family
designed for USB applications. All devices are based on a common industry-standard 8-bit
core, featuring an enhanced instruction set.
The ST7SCR ROM devices are factory-programmed and are not reprogrammable.
The ST7FSCR versions feature dual-voltage Flash memory with Flash Programming
capability.
They operate at a 4 MHz external oscillator frequency.
Under software control, all devices can be placed in WAIT or HALT mode, reducing power
consumption when the application is in idle or stand-by state.
The enhanced instruction set and addressing modes of the ST7 offer both power and
flexibility to software developers, enabling the design of highly efficient and compact
application code. In addition to standard 8-bit data management, all ST7 microcontrollers
feature true bit manipulation, 8x8 unsigned multiplication and indirect addressing modes.
The devices include an ST7 core, up to 16 Kbytes of program memory, up to 512 bytes of
user RAM, up to 35 I/O lines and the following on-chip peripherals:
●USB full speed interface with 7 endpoints, programmable in/out configuration and
embedded 3.3V voltage regulator and transceivers (no external components are
needed).
●ISO7816-3 UART interface with programmable baud rate from 372 clock pulses up to
11.625 clock pulses
●Smartcard Supply Block able to provide programmable supply voltage and I/O voltage
levels to the smartcards
●Low voltage reset ensuring proper power-on or power-off of the device (selectable by
Note:C1, C2, C7 and C8 must be located close to the chip.
Refer to Section 6: Supply, reset and clock management and Section 14.4.3 Crystal
resonator oscillators.
Doc ID 8951 Rev 615/121
Register and memory mapST7SCR1E4, ST7SCR1R4
0000h
Interrupt & Reset Vectors
HW Registers
0040h
003Fh
(see Table 4)
FFDFh
FFE0h
FFFFh
(see Table 11)
C000h
033Fh
Program Memory
RAM
USB RAM
(16K Bytes)
Short Addressing
Stack (128 Bytes)
0100h
0180h
023Fh
0040h
00FFh
017Fh
16-bit Addressing RAM
RAM (192 Bytes)
( 192 Bytes)
023Fh
0240h
256 Bytes
(512 Bytes)
Unused
3 Register and memory map
As shown in Figure 7, the MCU is capable of addressing 64K bytes of memories and I/O
registers.
The available memory locations consist of 40 bytes of register locations, up to 512 bytes of
RAM and up to 16K bytes of user program memory. The RAM space includes up to 128
bytes for the stack from 0100h to 017Fh.
The highest address bytes contain the user reset and interrupt vectors.
IMPORTANT: Memory locations noted “Reserved” must never be accessed. Accessing a
reserved area can have unpredictable effects on the device.
Smartcard Interface Control Register
Smartcard Interface Status Register
Smartcard Contact Control Register
Smartcard Elementary Time Unit 1
Smartcard Elementary Time Unit 0
Smartcard Guard time 1
Smartcard Guard time 0
Smartcard Character Waiting Time 2
Smartcard Character Waiting Time 1
Smartcard Character Waiting Time 0
Smartcard Interrupt Enable Register
Smartcard Interrupt Pending Register
Smartcard Transmit Buffer Register
Smartcard Receive Buffer Register
USB Interrupt Status Register
USB Interrupt Mask Register
USB Control Register
Device Address Register
USB Status Register
Endpoint 0 Register
EP 0 Reception Counter Register
EP 0 Transmission Counter Register
EP 1 Transmission Register
EP 1 Transmission Counter Register
EP 2 Reception Register
EP 2 Reception Counter Register
EP 2 Transmission Register
EP 2 Transmission Counter Register
EP 3 Transmission Register
EP 3 Transmission Counter Register
EP 4 Transmission Register
EP 4 Transmission Counter Register
EP 5 Transmission Register
EP 5 Transmission Counter Register
Error Status Register
The ST7 dual voltage High Density Flash (HDFlash) is a non-volatile memory that can be
electrically erased as a single block or by individual sectors and programmed on a Byte-byByte basis using an external V
The HDFlash devices can be programmed and erased off-board (plugged in a programming
tool) or on-board using ICP (In-Circuit Programming) or IAP (In-Application Programming).
The array matrix organization allows each sector to be erased and reprogrammed without
affecting other sectors.
4.2 Main features
●Three Flash programming modes:
–Insertion in a programming tool. In this mode, all sectors including option bytes
can be programmed or erased.
–ICP (In-Circuit Programming). In this mode, all sectors including option bytes can
be programmed or erased without removing the device from the application board.
–IAP (In-Application Programming) In this mode, all sectors except Sector 0, can be
programmed or erased without removing the device from the application board
and while the application is running.
●ICT (In-Circuit Testing) for downloading and executing user application test patterns in
RAM
●Read-out protection
●Register Access Security System (RASS) to prevent accidental programming or
erasing
supply.
PP
4.3 Structure
The Flash memory is organized in sectors and can be used for both code and data storage.
Depending on the overall FLASH memory size in the microcontroller device, there are up to
three user sectors (see Ta b l e 5 ). Each of these sectors can be erased independently to
avoid unnecessary erasing of the whole Flash memory when only a partial erasing is
required.
The first two sectors have a fixed size of 4 Kbytes (see Figure 8). They are mapped in the
upper part of the ST7 addressing space so the reset and interrupt vectors are located in
Sector 0 (F000h-FFFFh).
Table 5.Sectors available in FLASH devices
Flash Memory Size (bytes)Available Sectors
4KSector 0
8KSectors 0,1
> 8KSectors 0,1, 2
Doc ID 8951 Rev 619/121
Flash program memoryST7SCR1E4, ST7SCR1R4
4 Kbytes
4 Kbytes
SECTOR 1
SECTOR 0
SECTOR 2
16K USER FLASH MEMORY SIZE
FFFFh
F000h
EFFFh
E000h
DFFFh
C000h
8Kbytes
ex.: user program
ex.: user data
ex.: user system library
+ IAP BootLoader
+ library
Figure 8.Memory map and sector address
4.4 ICP (In-circuit programming)
To perform ICP the microcontroller must be switched to ICC (In-Circuit Communication)
mode by an external controller or programming tool.
Depending on the ICP code downloaded in RAM, Flash memory programming can be fully
customized (number of bytes to program, program locations, or selection serial
communication interface for downloading).
When using an STMicroelectronics or third-party programming tool that supports ICP and
the specific microcontroller device, the user needs only to implement the ICP hardware
interface on the application board (see Figure 9). For more details on the pin locations, refer
to the device pinout description.
ICP needs six signals to be connected to the programming tool. These signals are:
●V
●V
●OSCIN: to force the clock during power-up
●ICCCLK: ICC output serial clock pin
●ICCDATA: ICC input serial data pin
●V
: device power supply ground
SS
: for reset by LVD
DD
: ICC mode selection and programming voltage.
PP
If ICCCLK or ICCDATA are used for other purposes in the application, a serial resistor has to
be implemented to avoid a conflict in case one of the other devices forces the signal level.
Note:To develop a custom programming tool, refer to the ST7 FLASH Programming and ICC
Reference Manual which gives full details on the ICC protocol hardware and software.
4.5 IAP (In-application programming)
This mode uses a BootLoader program previously stored in Sector 0 by the user (in ICP
mode or by plugging the device in a programming tool).
This mode is fully controlled by user software. This allows it to be adapted to the user
application, (user-defined strategy for entering programming mode, choice of
communications protocol used to fetch the data to be stored, etc.). For example, it is
20/121Doc ID 8951 Rev 6
ST7SCR1E4, ST7SCR1R4Flash program memory
ICP PROGRAMMING TOOL CONNECTOR
10kΩ
C
L2
C
L1
ICCDATA
ICCCLK
V
SS
V
PP
OSCIN
OSCOUT
ST7
HE10 CONNECTOR TYPE
T
OT
HE
A
PP
LICATION
V
DD
4.7kΩ
APPLICATION BOARD
1
246810
975 3
PROGRAMMING TOOL
ICC CONNECTOR
ICC Cable
possible to download code from the USB interface and program it in the Flash. IAP mode
can be used to program any of the Flash sectors except Sector 0, which is write/erase
protected to allow recovery in case errors occur during the programming operation.
Figure 9.Typical ICP interface
Note:If the ICCCLK or ICCDATA pins are only used as outputs in the application, no signal
isolation is necessary. As soon as the Programming Tool is plugged to the board, even if an
ICC session is not in progress, the ICCCLK and ICCDATA pins are not available for the
application. If they are used as inputs by the application, isolation such as a serial resistor
has to implemented in case another device forces the signal. Refer to the Programming Tool
documentation for recommended resistor values.
4.6 Program memory read-out protection
The read-out protection is enabled through an option bit.
For Flash devices, when this option is selected, the program and data stored in the Flash
memory are protected against read-out (including a re-write protection). When this
protection is removed by reprogramming the Option Byte, the entire Flash program memory
is first automatically erased and the device can be reprogrammed.
Refer to the Option Byte description for more details.
4.7 Related documentation
For details on Flash programming and ICC protocol, refer to the ST7 Flash Programming
Reference Manual and to the ST7 ICC Protocol Reference Manual
.
Doc ID 8951 Rev 621/121
Flash program memoryST7SCR1E4, ST7SCR1R4
4.8 Register description
FLASH control/status register (FCSR)
Read/Write
Reset Value: 0000 0000 (00h)
70
00000000
This register is reserved for use by Programming Tool software. It controls the FLASH
programming and erasing operations. For details on customizing FLASH programming
methods and In-Circuit Testing, refer to the ST7 FLASH Programming and ICC Reference
Manual.
22/121Doc ID 8951 Rev 6
ST7SCR1E4, ST7SCR1R4Central processing unit
5 Central processing unit
5.1 Introduction
This CPU has a full 8-bit architecture and contains six internal registers allowing efficient 8bit data manipulation.
5.2 Main features
●Enable executing 63 basic instructions
●Fast 8-bit by 8-bit multiply
●17 main addressing modes (with indirect addressing mode)
●Two 8-bit index registers
●16-bit stack pointer
●Low power HALT and WAIT modes
●Priority maskable hardware interrupts
●Non-maskable software/hardware interrupts
5.3 CPU registers
The 6 CPU registers shown in Figure 10 are not present in the memory mapping and are
accessed by specific instructions.
Accumulator (A)
The Accumulator is an 8-bit general purpose register used to hold operands and the results
of the arithmetic and logic calculations and to manipulate data.
Index registers (X and Y)
These 8-bit registers are used to create effective addresses or as temporary storage areas
for data manipulation. (The Cross-Assembler generates a precede instruction (PRE) to
indicate that the following instruction refers to the Y register.)
The Y register is not affected by the interrupt automatic procedures.
Program counter (PC)
The program counter is a 16-bit register containing the address of the next instruction to be
executed by the CPU. It is made of two 8-bit registers PCL (Program Counter Low which is
the LSB) and PCH (Program Counter High which is the MSB).
Doc ID 8951 Rev 623/121
Central processing unitST7SCR1E4, ST7SCR1R4
ACCUMULATOR
X INDEX REGISTER
Y INDEX REGISTER
STACK POINTER
CONDITION CODE REGISTER
PROGRAM COUNTER
70
1C1I1HI0NZ
RESET VALUE = RESET VECTOR @ FFFEh-FFFFh
70
70
70
0
7
158
PCH
PCL
15
8
70
RESET VALUE = STACK HIGHER ADDRESS
RESET VALUE =
1X1 1 X1XX
RESET VALUE = XXh
RESET VALUE = XXh
RESET VALUE = XXh
X = Undefined Value
Figure 10. CPU registers
Condition code register (CC)
Read/Write
Reset Value: 111x1xxx
70
11I1HI0NZC
The 8-bit Condition Code register contains the interrupt masks and four flags representative
of the result of the instruction just 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.
Arithmetic management bits
Bit 4 = H Half carry.
This bit is set by hardware when a carry occurs between bits 3 and 4 of the ALU during an
ADD or ADC instructions. It is reset by hardware during the same instructions.
0: No half carry has occurred.
1: A half carry has occurred.
This bit is tested using the JRH or JRNH instruction. The H bit is useful in BCD arithmetic
subroutines.
Bit 2 = N Negative.
This bit is set and cleared by hardware. It is representative of the result sign of the last
arithmetic, logical or data manipulation. It’s a copy of the result 7
0: The result of the last operation 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 is accessed by the JRMI and JRPL instructions.
24/121Doc ID 8951 Rev 6
th
bit.
ST7SCR1E4, ST7SCR1R4Central processing unit
Bit 1 = Z Zero.
This bit is set and cleared by hardware. This bit 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 an
underflow has occurred during the last arithmetic operation.
0: No overflow or underflow has occurred.
1: An overflow or underflow has occurred.
This bit is driven by the SCF and RCF instructions and tested by the JRC and JRNC
instructions. It is also affected by the “bit test and branch”, shift and rotate instructions.
Interrupt Management Bits
Bit 5,3 = I1, I0 Interrupt
The combination of the I1 and I0 bits gives the current interrupt software priority.
Interrupt Software PriorityI1I0
Level 0 (main)10
Level 101
Level 200
Level 3 (= interrupt disable)11
These two bits are set/cleared by hardware when entering in interrupt. The loaded value is
given by the corresponding bits in the interrupt software priority registers (IxSPR). They can
be also set/cleared by software with the RIM, SIM, IRET, HALT, WFI and PUSH/POP
instructions.
See the interrupt management chapter for more details.
Stack Pointer (SP)
Read/Write
Reset Value: 017Fh
158
00000001
70
SP7SP6SP5SP4SP3SP2SP1SP0
The Stack Pointer is a 16-bit register which is always pointing to the next free location in the
stack. It is then decremented after data has been pushed onto the stack and incremented
before data is popped from the stack (see Figure 11).
Since the stack is 256 bytes deep, the 8 most significant bits are forced by hardware.
Following an MCU Reset, or after a Reset Stack Pointer instruction (RSP), the Stack Pointer
contains its reset value (the SP7 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 to the stack upper limit,
without indicating the stack overflow. The previously stored information is then overwritten
and therefore lost. The stack also wraps in case of an underflow.
The stack is used to save the return address during a subroutine call and the CPU context
during an interrupt. The user may also directly manipulate the stack by means of the PUSH
and POP instructions. In the case of an interrupt, the PCL is stored at the first location
pointed to by the SP. Then the other registers are stored in the next locations as shown in
Figure 11.
●When an interrupt is received, the SP is decremented and the context is pushed on the
stack.
●On return from interrupt, the SP is incremented and the context is popped from the
stack.
A subroutine call occupies two locations and an interrupt five locations in the stack area.
Figure 11. Stack manipulation example
26/121Doc ID 8951 Rev 6
ST7SCR1E4, ST7SCR1R4Supply, reset and clock management
PLL_
MISCR4
ON
-
-
----
LOCK
4 MHz
INTERNAL
8 MHz
CLOCK (f
CPU
)
4 MHz
PLL
X 12
48 MHz
USB
48 MHz
DIV
(f
OSC
)
CLK_
SEL
6 Supply, reset and clock management
6.1 Clock system
6.1.1 General description
The MCU accepts either a 4 MHz crystal or an external clock signal to drive the internal
oscillator. The internal clock (f
which is 4 MHz.
) is derived from the internal oscillator frequency (f
CPU
OSC
),
After reset, the internal clock (f
) is provided by the internal oscillator (4 MHz frequency).
CPU
To activate the 48-MHz clock for the USB interface, the user must turn on the PLL by setting
the PLL_ON bit in the MISCR4 register. When the PLL is locked, the LOCK bit is set by
hardware.
The user can then select an internal frequency (f
) of either 4 MHz or 8 MHz by
CPU
programming the CLK_SEL bit in the MISCR4 register (refer to Section 10: Miscellaneous
registers).
The PLL provides a signal with a duty cycle of 50%.
The internal clock signal (f
) is also routed to the on-chip peripherals. The CPU clock
CPU
signal consists of a square wave with a duty cycle of 50%.
Figure 12. Clock, reset and supply block diagram
The internal oscillator is designed to operate with an AT-cut parallel resonant quartz in the
frequency range specified for f
. The circuit shown in Figure 14 is recommended when
osc
using a crystal, and Ta b le 6 lists the recommended capacitance. The crystal and associated
components should be mounted as close as possible to the input pins in order to minimize
output distortion and start-up stabilization time. The LOCK bit in the MISCR4 register can
also be used to generate the f
directly from f
CPU
if the PLL and the USB interface are not
OSC
active.
Doc ID 8951 Rev 627/121
Supply, reset and clock managementST7SCR1E4, ST7SCR1R4
OSCIN
OSCOUT
EXTERNAL
CLOCK
NC
OSCIN
OSCOUT
C
OSCIN
C
OSCOUT
Table 6.Recommended values for 4 MHz crystal resonator
Note:R
R
SMAX
C
OSCIN
C
OSCOUT
is the equivalent serial resistor of the crystal (see crystal specification).
SMAX
20 Ω25 Ω70 Ω
56pF47pF22pF
56pF47pF22pF
6.1.2 External clock
An external clock may be applied to the OSCIN input with the OSCOUT pin not connected,
as shown on Figure 13.
Figure 13. External clock source connections
Figure 14. Crystal resonator
6.2 Reset sequence manager (RSM)
6.2.1 Introduction
The reset sequence manager has two reset sources:
●Internal LVD reset (Low Voltage Detection) which includes both a power-on and a
voltage drop reset
●Internal watchdog reset generated by an internal watchdog counter underflow as
shown in Figure 16.
6.2.2 Functional description
The reset service routine vector is fixed at addresses FFFEh-FFFFh in the ST7 memory
map.
The basic reset sequence consists of 3 phases as shown in Figure 15.
28/121Doc ID 8951 Rev 6
ST7SCR1E4, ST7SCR1R4Supply, reset and clock management
DELAY 1
RUN
LVD
RESET
FETCH VECTOR (2 t
CPU
)
DELAY 2
LVD
RESET
INTERNAL
RESET
DELAY 1 = 30µs + 127 t
CPU
DELAY 2 = 512 t
CPU
V
DD
V
IT+
V
IT-
WATCHDOG
WATCHDOG UNDERFLOW
RESET
FETCH VECTOR (2 t
CPU
)
DELAY 1
WATCHDOG
RESET
DELAY 2
DELAY 1 = 30µs + 127 t
CPU
DELAY 2 = 512 t
CPU
RUN
1.A first delay of 30µs + 127 t
2. A second delay of 512 t
CPU
cycles during which the internal reset is maintained.
CPU
cycles after the internal reset is generated. It allows the
oscillator to stabilize and ensures that recovery has taken place from the Reset state.
3. Reset vector fetch (duration: 2 clock cycles)
Low voltage detector
The low voltage detector generates a reset when V
edge), as shown in Figure 15.
The LVD filters spikes on V
larger than t
DD
Supply and reset characteristics.
Note:It is recommended to make sure that the V
device is exiting from Reset, to ensure the application functions properly.
Figure 15. LVD RESET sequence
DD<VIT+
to avoid parasitic resets. See Section 14.3
g(VDD)
supply voltage rises monotonously when the
DD
(rising edge) or VDD<V
IT-
(falling
Figure 16. Watchdog RESET sequence
Doc ID 8951 Rev 629/121
InterruptsST7SCR1E4, ST7SCR1R4
7 Interrupts
7.1 Introduction
The CPU enhanced interrupt management provides the following features:
●Hardware interrupts
●Software interrupt (TRAP)
●Nested or concurrent interrupt management with flexible interrupt priority and level
management:
–Up to 4 software programmable nesting levels
–Up to 16 interrupt vectors fixed by hardware
–3 non maskable events: RESET, TRAP, TLI
This interrupt management is based on:
●Bit 5 and bit 3 of the CPU CC register (I1:0),
●Interrupt software priority registers (ISPRx),
●Fixed interrupt vector addresses located at the high addresses of the memory map
(FFE0h to FFFFh) sorted by hardware priority order.
This enhanced interrupt controller guarantees full upward compatibility with the standard
(not nested) CPU interrupt controller.
7.2 Masking and processing flow
The interrupt masking is managed by the I1 and I0 bits of the CC register and the ISPRx
registers which give the interrupt software priority level of each interrupt vector (see
Ta bl e 7 ). The processing flow is shown in Figure 17.
When an interrupt request has to be serviced:
●Normal processing is suspended at the end of the current instruction execution.
●The PC, X, A and CC registers are saved onto the stack.
●I1 and I0 bits of CC register are set according to the corresponding values in the ISPRx
registers of the serviced interrupt vector.
●The PC is then loaded with the interrupt vector of the interrupt to service and the first
instruction of the interrupt service routine is fetched (refer to “Interrupt Mapping” table
for vector addresses).
The interrupt service routine should end with the IRET instruction which causes the
contents of the saved registers to be recovered from the stack.
Note:As a consequence of the IRET instruction, the I1 and I0 bits will be restored from the stack
and the program in the previous level will resume.
30/121Doc ID 8951 Rev 6
Loading...
+ 91 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.