STM8S903K3
STM8S903K3
Interrupt management
• Nested interrupt controller with 32 interrupts
LQFP32 7x7 UFQFPN32 5x5 SDIP32 400 mils
• Up to 28 external interrupts on 7 vectors
Timers
• Advanced control timer: 16-bit, 4 CAPCOM
channels, 3 complementary outputs, dead-time
insertion and flexible synchronization
• 16-bit general purpose timer, with 3 CAPCOM
channels (IC, OC or PWM)
• 8-bit basic timer with 8-bit prescaler
TSSOP20 UFQFPN20 3x3 SO20W 300 mils
• Program memory: 8 Kbytes Flash; data retention Analog to digital converter (ADC)
20 years at 55 °C after 10 kcycles
• 10-bit, ±1 LSB ADC with up to 7 muxed channels
• Data memory: 640 bytes true data EEPROM;
endurance 300 kcycles
+ 1 internal channel, scan mode and analog
watchdog
• RAM: 1 Kbytes • Internal reference voltage measurement
Clock, reset and supply management I/Os
• 2.95 to 5.5 V operating voltage • Up to 28 I/Os on a 32-pin package including 21
• Flexible clock control, 4 master clock sources:
high sink outputs
• Highly
- Low power crystal resonator oscillator robust I/O design, immune against current
Contents
1 Introduction ..............................................................................................................8
2 Description ...............................................................................................................9
3 Block diagram ........................................................................................................10
4 Product overview ...................................................................................................11
4.1 Central processing unit STM8 .....................................................................................11
4.2 Single wire interface module (SWIM) and debug module (DM) ..................................11
4.3 Interrupt controller .......................................................................................................12
4.4 Flash program and data EEPROM memory ................................................................12
4.5 Clock controller ............................................................................................................13
4.6 Power management ....................................................................................................14
4.7 Watchdog timers ..........................................................................................................14
4.8 Auto wakeup counter ...................................................................................................15
4.9 Beeper ........................................................................................................................15
4.10 TIM1 - 16-bit advanced control timer .........................................................................15
4.11 TIM5 - 16-bit general purpose timer ..........................................................................16
4.12 TIM6 - 8-bit basic timer ..............................................................................................16
4.13 Analog-to-digital converter (ADC1) ............................................................................16
4.14 Communication interfaces .........................................................................................17
4.14.1 UART1 ...............................................................................................17
4.14.2 SPI .....................................................................................................18
4.14.3 I²C ......................................................................................................18
5 Pinout and pin description ...................................................................................19
5.1 STM8S903F3 TSSOP20/SO20 pinout ........................................................................20
5.2 STM8S903F3 UFQFPN20 pinout ................................................................................21
5.3 TSSOP/SO/UFQFPN20 pin description ......................................................................22
5.4 STM8S903K3 UFQFPN32/LQFP32/SDIP32 pinout ....................................................23
5.5 UFQFPN/LQFP/SDIP32 pin description ......................................................................24
5.6 Alternate function remapping .......................................................................................26
6 Memory and register map .....................................................................................27
6.1 Memory map ................................................................................................................27
6.2 Register map ...............................................................................................................28
6.2.1 I/O port hardware register map ............................................................28
6.2.2 General hardware register map ...........................................................29
6.2.3 CPU/SWIM/debug module/interrupt controller registers .....................38
7 Interrupt vector mapping ......................................................................................41
8 Option bytes ...........................................................................................................43
8.1 STM8S903K3/F3 alternate function remapping bits ....................................................45
9 Unique ID ................................................................................................................49
10 Electrical characteristics ....................................................................................50
10.1 Parameter conditions .................................................................................................50
10.1.1 Minimum and maximum values .........................................................50
10.1.2 Typical values .....................................................................................50
10.1.3 Typical curves ....................................................................................50
10.1.4 Loading capacitor ...............................................................................50
10.1.5 Pin input voltage .................................................................................50
10.2 Absolute maximum ratings ........................................................................................51
10.3 Operating conditions ..................................................................................................53
10.3.1 VCAP external capacitor ....................................................................54
10.3.2 Supply current characteristics ............................................................55
10.3.3 External clock sources and timing characteristics .............................65
10.3.4 Internal clock sources and timing characteristics ...............................67
10.3.5 Memory characteristics ......................................................................69
10.3.6 I/O port pin characteristics .................................................................70
10.3.7 Reset pin characteristics ....................................................................78
10.3.8 SPI serial peripheral interface ............................................................81
2
10.3.9 I C interface characteristics ...............................................................84
10.3.10 10-bit ADC characteristics ................................................................85
10.3.11 EMC characteristics .........................................................................89
11 Package information ............................................................................................92
11.1 32-pin LQFP package mechanical data .....................................................................92
11.2 32-lead UFQFPN package mechanical data .............................................................94
11.3 20-lead UFQFPN package mechanical data .............................................................95
11.4 UFQFPN recommended footprint ..............................................................................97
11.5 SDIP32 package mechanical data .............................................................................98
11.6 20-pin TSSOP package mechanical data ................................................................100
11.7 20-pin SO package mechanical data .......................................................................101
11.8 Thermal characteristics ............................................................................................102
11.8.1 Reference document ........................................................................103
11.8.2 Selecting the product temperature range .........................................103
12 Ordering information .........................................................................................104
12.1 STM8S903K3/F3 FASTROM microcontroller option list ..........................................104
13 STM8 development tools ..................................................................................110
13.1 Emulation and in-circuit debugging tools .................................................................110
13.2 Software tools ..........................................................................................................110
13.2.1 STM8 toolset ....................................................................................111
13.2.2 C and assembly toolchains ..............................................................111
13.3 Programming tools ..................................................................................................111
14 Revision history .................................................................................................112
List of tables
Table 1. STM8S903K3/F3 access line features .......................................................................................9
Table 2. Peripheral clock gating bit assignments in CLK_PCKENR1/2 registers ..................................14
Table 3. TIM timer features ....................................................................................................................16
Table 4. Legend/abbreviations for pinout tables ...................................................................................19
Table 5. TSSOP20/SO20/UFQFPN20 pin description ...........................................................................24
Table 6. UFQFPN32/LQFP32/SDIP32 pin description ...........................................................................24
Table 7. I/O port hardware register map ................................................................................................28
Table 8. General hardware register map ................................................................................................43
Table 9. CPU/SWIM/debug module/interrupt controller registers .........................................................54
Table 10. Interrupt mapping ...................................................................................................................41
Table 11. Option bytes .........................................................................................................................112
Table 12. Option byte description ...........................................................................................................43
Table 13. STM8S903K3 alternate function remapping bits [7:2] for 32-pin packages ...........................45
Table 14. STM8S903F3 alternate function remapping bits [7:2] for 20-pin packages ...........................46
Table 15. STM8S903K3 alternate function remapping bits [1:0] for 32-pin packages .........................102
Table 16. STM8S903F3 alternate function remapping bits [1:0] for 20-pin packages ...........................48
Table 17. Unique ID registers (96 bits) .................................................................................................112
Table 18. Voltage characteristics ...........................................................................................................51
Table 19. Current characteristics ...........................................................................................................51
Table 20. Thermal characteristics ..........................................................................................................52
Table 21. General operating conditions .................................................................................................53
Table 22. Operating conditions at power-up/power-down ......................................................................54
Table 23. Total current consumption with code execution in run mode at VDD = 5 V .............................55
Table 24. Total current consumption with code execution in run mode at VDD = 3.3 V ..........................56
Table 25. Total current consumption in wait mode at VDD = 5 V ............................................................57
Table 26. Total current consumption in wait mode at VDD = 3.3 V .........................................................57
Table 27. Total current consumption in active halt mode at VDD = 5 V ..................................................58
Table 28. Total current consumption in active halt mode at VDD = 3.3 V ...............................................59
Table 29. Total current consumption in halt mode at VDD = 5 V .............................................................60
Table 30. Total current consumption in halt mode at VDD = 3.3 V ..........................................................60
Table 31. Wakeup times .........................................................................................................................60
Table 32. Total current consumption and timing in forced reset state ....................................................61
Table 33. Peripheral current consumption .............................................................................................62
Table 34. HSE user external clock characteristics .................................................................................65
Table 35. HSE oscillator characteristics .................................................................................................65
Table 36. HSI oscillator characteristics ..................................................................................................67
Table 37. LSI oscillator characteristics ...................................................................................................68
Table 38. RAM and hardware registers ..................................................................................................69
Table 39. Flash program memory/data EEPROM memory ....................................................................69
Table 40. I/O static characteristics .........................................................................................................70
Table 41. Output driving current (standard ports) ..................................................................................72
Table 42. Output driving current (true open drain ports) ........................................................................73
Table 43. Output driving current (high sink ports) ..................................................................................73
Table 44. NRST pin characteristics ........................................................................................................78
Table 45. SPI characteristics ..................................................................................................................81
2
Table 46. I C characteristics ..................................................................................................................84
Table 47. ADC characteristics ................................................................................................................85
List of figures
Figure 1. Block diagram .........................................................................................................................10
Figure 2. Flash memory organization ....................................................................................................13
Figure 3. STM8S903F3 TSSOP20/SO20 pinout ...................................................................................23
Figure 4. STM8S903F3 UFQFPN20 pinout ...........................................................................................23
Figure 5. STM8S903K3 UFQFPN32/LQFP32 pinout ............................................................................23
Figure 6. STM8S903K3 SDIP32 pinout .................................................................................................24
Figure 7. Memory map ...........................................................................................................................27
Figure 8. Pin loading conditions .............................................................................................................50
Figure 9. Pin input voltage .....................................................................................................................51
Figure 10. fCPUmax versus VDD ..............................................................................................................54
Figure 11. External capacitor CEXT .......................................................................................................55
Figure 12. Typ IDD(RUN) vs. VDD HSE user external clock, fCPU = 16 MHz .............................................62
Figure 13. Typ IDD(RUN) vs. fCPU HSE user external clock, VDD = 5 V ....................................................63
Figure 14. Typ IDD(RUN) vs. VDD HSI RC osc, fCPU = 16 MHz .................................................................63
Figure 15. Typ IDD(WFI) vs. VDD HSE user external clock, fCPU = 16 MHz ..............................................64
Figure 16. Typ IDD(WFI) vs. fCPU HSE user external clock, VDD = 5 V .....................................................64
Figure 17. Typ IDD(WFI) vs. VDD HSI RC osc, fCPU = 16 MHz .................................................................64
Figure 18. HSE external clocksource .....................................................................................................65
Figure 19. HSE oscillator circuit diagram ...............................................................................................66
Figure 20. Typical HSI frequency variation vs VDD @ 4 temperatures ..................................................68
Figure 21. Typical LSI frequency variation vs VDD @ 4 temperatures ...................................................68
Figure 22. Typical VIL and VIH vs VDD @ 4 temperatures ......................................................................71
Figure 23. Typical pull-up resistance vs VDD @ 4 temperatures ............................................................72
Figure 24. Typical pull-up current vs VDD @ 4 temperatures .................................................................72
Figure 25. Typ. VOL @ VDD = 5 V (standard ports) ................................................................................74
Figure 26. Typ. VOL @ VDD = 3.3 V (standard ports) .............................................................................74
Figure 27. Typ. VOL @ VDD = 5 V (true open drain ports) ......................................................................75
Figure 28. Typ. VOL @ VDD = 3.3 V (true open drain ports) ...................................................................75
Figure 29. Typ. VOL @ VDD = 5 V (high sink ports) ................................................................................76
Figure 30. Typ. VOL @ VDD = 3.3 V (high sink ports) .............................................................................76
Figure 31. Typ. VDD - VOH@ VDD = 5 V (standard ports) .......................................................................77
Figure 32. Typ. VDD - VOH @ VDD = 3.3 V (standard ports) ...................................................................77
Figure 33. Typ. VDD - VOH@ VDD = 5 V (high sink ports) .......................................................................78
Figure 34. Typ. VDD - VOH@ VDD = 3.3 V (high sink ports) ....................................................................78
Figure 35. Typical NRST VIL and VIH vs VDD @ 4 temperatures ...........................................................79
Figure 36. Typical NRST pull-up resistance vs VDD @ 4 temperatures .................................................80
Figure 37. Typical NRST pull-up current vs VDD @ 4 temperatures ......................................................80
Figure 38. Recommended reset pin protection ......................................................................................81
Figure 39. SPI timing diagram - slave mode and CPHA = 0 ..................................................................83
Figure 40. SPI timing diagram - slave mode and CPHA = 1 ..................................................................83
(1)
Figure 41. SPI timing diagram - master mode ...................................................................................84
2
Figure 42. Typical application with I C bus and timing diagram ............................................................85
Figure 43. ADC accuracy characteristics ...............................................................................................88
Figure 44. Typical application with ADC ................................................................................................88
Figure 45. 32-pin low profile quad flat package (7 x 7) ..........................................................................92
Figure 46. 32-lead, ultra thin, fine pitch quad flat no-lead package (5 x 5) ............................................94
Figure 47. 20-lead, ultra thin, fine pitch quad flat no-lead package outline (3 x 3) ................................95
1 Introduction
This datasheet contains the description of the device features, pinout, electrical characteristics,
mechanical data and ordering information.
• For complete information on the STM8S microcontroller memory, registers and peripherals,
please refer to the STM8S microcontroller family reference manual (RM0016).
• For information on programming, erasing and protection of the internal Flash memory
please refer to the STM8S Flash programming manual (PM0051).
• For information on the debug and SWIM (single wire interface module) refer to the STM8
SWIM communication protocol and debug module user manual (UM0470).
• For information on the STM8 core, please refer to the STM8 CPU programming manual
(PM0044).
2 Description
The STM8S903K3 and STM8S903F3 8-bit microcontrollers offer 8 Kbytes Flash program
memory, plus integrated true data EEPROM. The STM8S microcontroller family reference
manual (RM0016) refers to devices in this family as low-density. They provide the following
benefits: performance, robustness, and reduced system cost.
Device performance and robustness are ensured by advanced core and peripherals made
in a state-of-the art technology, a 16 MHz clock frequency, robust I/Os, independent watchdogs
with separate clock source, and a clock security system.
The system cost is reduced thanks to an integrated true data EEPROM for up to 300
kwrite/erase cycles and a high system integration level with internal clock oscillators, watchdog
and brown-out reset.
Full documentation is offered as well as a wide choice of development tools.
Timer CAPCOM 7
channels
Timer complementary 3 2
outputs
RAM (bytes) 1K
2
Peripheral set Multipurpose timer (TIM1), SPI, I C, UART window WDG,
independent WDG, ADC, PWM timer (TIM5), 8-bit timer (TIM6)
(1)
Including 21 high sink outputs
(2)
Including 12 high sink outputs
(3)
No read-while-write (RWW) capability
3 Block diagram
Figure 1: Block diagram
Detector
POR BOR RC int. 128 kHz
Window WDG
STM8 core
Independent WDG
640 bytes
data EEPROM
Address and data bus
8 Mbit/s SPI
Up to
4 CAPCOM
16-bit advanced control
LIN master UART1 channels
timer (TIM1)
SPI emul. + 3 complementar
outputs
16-bit general purpose
Up to
Timer (TIM5)
3 CAPCOM
channels
8-bit basic timer
Up to 7 ADC1 (TIM6)
channels
4 Product overview
The following section intends to give an overview of the basic features of the device functional
modules and peripherals.
For more detailed information please refer to the corresponding family reference manual
(RM0016).
• Stack pointer relative addressing mode for local variables and parameter passing
Instruction set
• 80 instructions with 2-byte average instruction size
• Standard data movement and logic/arithmetic functions
• 8-bit by 8-bit multiplication
• 16-bit by 8-bit and 16-bit by 16-bit division
• Bit manipulation
• Data transfer between stack and accumulator (push/pop) with direct stack access
• Data transfer using the X and Y registers or direct memory-to-memory transfers
4.2 Single wire interface module (SWIM) and debug module (DM)
The single wire interface module and debug module permits non-intrusive, real-time in-circuit
debugging and fast memory programming.
SWIM
Single wire interface module for direct access to the debug module and memory programming.
The interface can be activated in all device operation modes. The maximum data transmission
speed is 145 bytes/ms.
Debug module
The non-intrusive debugging module features a performance close to a full-featured emulator.
Beside memory and peripherals, also CPU operation can be monitored in real-time by means
of shadow registers.
• R/W to RAM and peripheral registers in real-time
• R/W access to all resources by stalling the CPU
• Breakpoints on all program-memory instructions (software breakpoints)
• Two advanced breakpoints, 23 predefined configurations
4.3 Interrupt controller
• Nested interrupts with three software priority levels
• 32 interrupt vectors with hardware priority
• Up to 28 external interrupts on 7 vectors including TLI
• Trap and reset interrupts
4.4 Flash program and data EEPROM memory
• 8 Kbytes of Flash program single voltage Flash memory
• 640 bytes true data EEPROM
• User option byte area
Write protection (WP)
Write protection of Flash program memory and data EEPROM is provided to avoid unintentional
overwriting of memory that could result from a user software malfunction.
There are two levels of write protection. The first level is known as MASS (memory access
security system). MASS is always enabled and protects the main Flash program memory,
data EEPROM and option bytes.
To perform in-application programming (IAP), this write protection can be removed by writing
a MASS key sequence in a control register. This allows the application to write to data
EEPROM, modify the contents of main program memory or the device option bytes.
A second level of write protection, can be enabled to further protect a specific area of memory
known as UBC (user boot code). Refer to the figure below.
The size of the UBC is programmable through the UBC option byte, in increments of 1 page
(64-byte block) by programming the UBC option byte in ICP mode.
This divides the program memory into two areas:
• Main program memory: Up to 8 Kbytes minus UBC
• User-specific boot code (UBC): Configurable up to 8 Kbytes
The UBC area remains write-protected during in-application programming. This means that
the MASS keys do not unlock the UBC area. It protects the memory used to store the boot
program, specific code libraries, reset and interrupt vectors, the reset routine and usually the
IAP and communication routines.
Figure 2: Flash memory organization
Programmable
UBC area area from 64
Remains write protected during IAP bytes(1 page)
up to 8 Kbytes
(in 1 page steps)
Low density
Flash program
memory
(8 Kbytes)
Program memory area
Write access possible for IAP
Features
• Clock prescaler: To get the best compromise between speed and current consumption
the clock frequency to the CPU and peripherals can be adjusted by a programmable
prescaler.
• Safe clock switching: Clock sources can be changed safely on the fly in run mode
through a configuration register. The clock signal is not switched until the new clock source
is ready. The design guarantees glitch-free switching.
• Clock management: To reduce power consumption, the clock controller can stop the
clock to the core, individual peripherals or memory.
• Master
clock:
clock sources: Four different clock sources can be used to drive the master
• Startup clock: After reset, the microcontroller restarts by default with an internal 2 MHz
clock (HSI/8). The prescaler ratio and clock source can be changed by the application
program as soon as the code execution starts.
• Clock security system (CSS): This feature can be enabled by software. If an HSE clock
failure occurs, the internal RC (16 MHz/8) is automatically selected by the CSS and an
interrupt can optionally be generated.
• Configurable
application.
main clock output (CCO): This outputs an external clock for use by the
Activation of the watchdog timers is controlled by option bytes or by software. Once activated,
the watchdogs cannot be disabled by the user program without performing a reset.
• Synchronization
TIM5 or TIM6
module to control the timer with external signals or to synchronise with
Main features
• One Mbit/s full duplex SCI
• SPI emulation
• High precision baud rate generator
• Smartcard emulation
• IrDA SIR encoder decoder
• LIN master mode
• Single wire half duplex mode
Asynchronous communication (UART mode)
• Full duplex communication - NRZ standard format (mark/space)
• following
Programmable transmit and receive baud rates up to 1 Mbit/s (f /16) and capable of
CPU
any standard baud rate regardless of the input frequency
• Separate enable bits for transmitter and receiver
• TwoAddress
receiver wakeup modes:
- bit (MSB)
- Idle line (interrupt)
Output speed
O1 = Slow (up to 2 MHz)
O2 = Fast (up to 10 MHz)
O3 = Fast/slow programmability with slow as default state after reset
O4 = Fast/slow programmability with fast as default state after reset
Reset state
Bold X (pin state after internal reset release).
Unless otherwise specified, the pin state is the same during the reset
phase and after the internal reset release.
TIM5_CH1[UART1_CK]BEEP/PD4(HS) 1 20 PD3(HS)/AIN4/TIM5_CH2/ADC_ETR
AIN5/UART1_TX/PD5(HS) 2 19 PD2(HS)/AIN3[TIM5_CH3]
AIN6/UART1_RX/PD6(HS) 3 18 PD1(HS)/SWIM
NRST 4 17 PC7(HS)/SPI_MISO[TIM1_CH2]
OSCIN/PA1 5 16 PC6(HS)/SPI_MOSI[TIM1_CH1]
OSCOUT/PA2 6 15 PC5(HS)/SPI_SCK[TIM5_CH1]
VSS 7 14 PC4(HS)/TIM1_CH4/CLK_CCO/AIN2/[TIM1_CH2N]
VCAP 8 13 PC3(HS)/TIM1_CH3[TLI][TIM1_CH1N]
VDD 9 12 PB4(T)/I2C_SCL[ADC_ETR]
[SPI_NSS]/TIM5_CH3/PA3(HS) 10 11 PB5(T)/[TIM1_BKIN]I2C_SDA
20 19 18 17 16
NRST 1 15
PD1(HS)/SWIM
OSCIN/PA1 2 14 PC7(HS)/SPI_MISO/[TIM1_CH2]
OSCOUT/PA2 3 13 PC6(HS)/SPI_MOSI/[TIM1_CH1]
VSS 4 12 PC5 (HS)/SPI_SCK/[TIM5_CH1]
VCAP 5 11 PC4(HS)/TIM1_CH4/CLK_CCO/AIN2/[TIM1_CH2N]
6 7 8 9 10
[UART1_TX]/[SPI_NSS]/TIM5_CH3/(HS) PA3
VDD
[ADC_ETR]/I2C_SCL/(T)PB4
[TIM1_BKIN]/I2C_SDA/(T)PB5
[TIM1_CH1N]/[TLI]/TIM1_CH3/(HS)PC3
(2)
5 2 PA1/ OSCIN I/O X X X O1 X X Port Resonator/ crystal in
A1
10 7 PA3/ TIM5_CH3 [SPI_NSS] I/O X X X HS O3 X X Port Timer 52 channel 3 SPI master/ slave select [AFR1]/
[UART1_TX] A3 UART1 data transmit [AFR1:0]
(3) 2
11 8 PB5/ I2C_SDA [TIM1_BKIN] I/O X X O1 T Port I C data Timer 1 - break input [AFR4]
B5
(3) 2
12 9 PB4/ I2C_SCL [ADC_ETR] I/O X X O1 T Port I C clock ADC external trigger [AFR4]
B4
13 10 PC3/ I/O X X X HS O3 X X Port Timer 1 - channel 3 Top level interrupt [AFR3] Timer
TIM1_CH3/TLI/[TIM1_CH1N ] C3 1 inverted channel 1 [AFR7]
16 13 PC6/ SPI_MOSI [TIM1_CH1] I/O X X X HS O3 X X Port PI master out/slave in Timer 1 channel 1 [AFR0]
C6
17 14 PC7/ SPI_MISO [TIM1_CH2] I/O X X X HS O3 X X Port SPI master in/ slave out Timer 1 channel 2[AFR0]
C7
(4)
18 15 PD1/ SWIM I/O X X X HS O4 X X Port SWIM data interface
D1
1 18 PD4/ TIM5_CH1/ BEEP I/O X X X HS O3 X X Port Timer 5 - channel 1/BEEP UART clock [AFR2]
[UART1_CK] D4 output
(1)
I/O pins used simultaneously for high current source/sink must be uniformly spaced around the package. In addition, the total driven current must respect the absolute maximum ratings ( see section
"Absolute maximum ratings").
(2)
When the MCU is in Halt/Active-halt mode, PA1 is automatically configured in input weak pull-up and cannot be used for waking up the device. In this mode, the output state of PA1 is not driven. It is
recommended to use PA1 only in input mode if Halt/Active-halt is used in the application.
(3)
In the open-drain output column, ‘T’ defines a true open-drain I/O (P-buffer, weak pull-up, and protection diode to VDD are not implemented)
(4)
The PD1 pin is in input pull-up during the reset phase and after internal reset release.
PD1 (HS)/SWIM
32 31 30 29 28 27 26 25
NRST 1 24 PC7 (HS)/SPI_MISO [TIM1_CH2]
OSCIN/PA1 2 23 PC6 (HS)/SPI_MOSI [TIM1_CH1]
OSCOUT/PA2 3 22 PC5 (HS)/SPI_SCK [TIM5_CH1]
VSS 4 21 PC4 (HS)/TIM1_CH4/CLK_CCO [AIN2] [TIM1_CH2N]
VCAP 5 20 PC3 (HS)/TIM1_CH3 [TLI] [TIM1_CH1N]
VDD 6 19 PC2 (HS)/TIM1_CH2 [TIM1_CH3N]
[UART1_TX] [SPI_NSS] TIM5_CH3/(HS) PA3 7 18 PC1 (HS)/TIM1_CH1/UART1_CK [TIM1_CH2N]
[UART1_RX] PF4 8 17 PE5/SPI_NSS [TIM1_CH1N]
9 10 11 12 13 14 15 16
PB7
PB6
[TIM1_BKIN] I C_SDA/(T) PB5
[ADC_ETR] I C_SCL/(T) PB4
TIM1_ETR/AIN3/(HS) PB3
TIM1_CH3N/AIN2/(HS) PB2
TIM1_CH2N/AIN1/(HS) PB1
TIM1_CH1N/AIN0/(HS) PB0
2
2
AIN4/TIM5_CH2/ADC_ETR/PD3(HS) 1 32 PD2(HS)[AIN3][TIM5_CH3]
TIM5_CH1[UART1_CK]BEEP/PD4(HS) 2 31 PD1(HS)/SWIM
AIN5/UART1_TX/PD5(HS) 3 30 PD0(HS)/TIM1_BKIN[CLK_CCO]
AIN6/UART1_RX/PD6(HS) 4 29 PC7(HS)/SPI_MISO[TIM1_CH2]
[TIM1_CH4]TLI/PD7(HS) 5 28 PC6(HS)/SPI_MOSI[TIM1_CH1]
NRST 6 27 PC5(HS)/SPI_SCK[TIM5_CH1]
OSCIN/PA1 7 26 PC4(HS)/TIM1_CH4/CLK_CCO[AIN2][TIM1_CH2N]
OSCOUT/PA2 8 25 PC3(HS)/TIM1_CH3[TLI][TIM1_CH1N]
VSS 9 24 PC2(HS)/TIM1_CH2[TIM1_CH3N]
VCAP 10 23 PC1(HS)/TIM1_CH1/UART1_CK[TIM1_CH2N]
VDD 11 22 PE5/SPI_NSS[TIM1_CH1N]
[UART1_TX][SPI_NSS]/TIM5_CH3/PA3(HS) 12 21 PB0(HS)/AIN0/TIM1_CH1N
[UART1_RX]/PF4 13 20 PB1(HS)/AIN1/TIM1_CH2N
PB7 14 19 PB2(HS)/AIN2/TIM1_CH3N
PB6 15 18 PB3(HS)[AIN3]TIM1_ETR
[TIM1_BKIN]I2C_SDA/PB5(T) 16 17 PB4(T)/I2C_SCL[ADC_ETR]
(2)
7 2 PA1/ OSCIN I/O X X X O1 X X Port Resonator/ crystal in
A1
12 7 PA3/ TIM5_CH3 [SPI_NSS] I/O X X X HS O3 X X Port Timer 52 channel 3 SPI master/ slave select
[UART1_TX] A3 [AFR1]/ UART1 data transmit
[AFR1:0]
Input Output Main Default alternate function Alternate function after remap
SDIP UFQFPN/ Pin name Type
function [option bit]
32 LQFP32 floating wpu Ext. High Speed OD PP (after
(1)
interrupt sink reset)
(3) 2
16 11 PB5/ I2C_SDA [TIM1_BKIN] I/O X X O1 T Port I C data Timer 1 - break input [AFR4]
B5
(3) 2
17 12 PB4/ I2C_SCL [ADC_ETR] I/O X X O1 T Port I C clock ADC external trigger [AFR4]
B4
22 17 PE5/ SPI_NSS [TIM1_CH1N] I/O X X X HS O3 X X Port SPI master/ slave select Timer 1 - inverted channel 1
E5 [AFR1:0]
23 18 PC1/ TIM1_CH1/ UART1_CK I/O X X X HS O3 X X Port Timer 1 - channel 1 Timer 1 - inverted channel 2
[TIM1_CH2N] C1 UART1 clock [AFR1:0]
24 19 PC2/ TIM1_CH2 [TIM1_CH3N] I/O X X X HS O3 X X Port Timer 1 - channel 2 Timer 1 - inverted channel 3
C2 [AFR1:0]
25 20 PC3/ TIM1_CH3/TLI/[TIM1_CH1N I/O X X X HS O3 X X Port Timer 1 - channel 3 Top level interrupt [AFR3] Timer
] C3 1 inverted channel 1 [AFR7]
28 23 PC6/ SPI_MOSI [TIM1_CH1] I/O X X X HS O3 X X Port PI master out/slave in Timer 1 channel 1 [AFR0]
C6
29 24 PC7/ SPI_MISO [TIM1_CH2] I/O X X X HS O3 X X Port SPI master in/ slave out Timer 1 channel 2[AFR0]
C7
30 25 PD0/ TIM1_BKIN [CLK_CCO] I/O X X X HS O3 X X Port Timer 1 - break input Configurable clock output
D0 [AFR5]
(4)
31 26 PD1/ SWIM I/O X X X HS O4 X X Port SWIM data interface
D1
2 29 PD4/ TIM5_CH1/ BEEP I/O X X X HS O3 X X Port Timer 5 - channel 1/BEEP UART clock [AFR2]
[UART1_CK] D4 output
5 32 PD7/ TLI [TIM1_CH4] I/O X X X HS O3 X X Port Top level interrupt Timer 1 - channel 4 [AFR6]
D7
(1)
I/O pins used simultaneously for high current source/sink must be uniformly spaced around the package. In addition, the total driven current must respect the absolute maximum ratings ( see section
"Absolute maximum ratings").
(2)
When the MCU is in Halt/Active-halt mode, PA1 is automatically configured in input weak pull-up and cannot be used for waking up the device. In this mode, the output state of PA1 is not driven. It is
recommended to use PA1 only in input mode if Halt/Active-halt is used in the application.
(3)
In the open-drain output column, ‘T’ defines a true open-drain I/O (P-buffer, weak pull-up, and protection diode to VDD are not implemented)
(4)
The PD1 pin is in input pull-up during the reset phase and after internal reset release.
0x00 0000
RAM
(1 Kbyte)
Reserved
0x00 3FFF
0x00 4000
640 bytes data EEPROM
0x00 427F
0x00 4280
Reserved
0x00 47FF
0x00 4800 Option bytes
0x00 480A
0x00 480B Reserved
0x00 4864
0x00 4865
0x00 4870
Unique ID
0x00 4871
Reserved
0x00 4FFF
0x00 5000
GPIO and periph. reg.
0x00 57FF
0x00 5800
Reserved
0x00 7EFF
0x00 7F00
CPU/SWIM/debug/ITC
registers
0x00 7FFF
0x00 8000
32 interrupt vectors
0x00 807F
0x00 8080 Flash program memory
0x00 9FFF
(8 Kbytes)
0x00 A000
Reserved
Reset
Address Block Register label Register name
status
0x00 5018 Port E PE_CR2 Port E control register 2 0x00
(1)
Depends on the external circuitry.
Reserved
0x00 5215
2
I2C_DR I C data register 0x00
0x00 5216
2
I2C_SR1 I C status register 1 0x00
0x00 5217
2
I2C_SR2 I C status register 2 0x00
0x00 5218
2
I2C_SR3 I C status register 3 0x0x
0x00 5219
2
I2C_ITR I C interrupt control register 0x00
0x00 521A
2
I2C_CCRL I C Clock control register low 0x00
0x00 521B
TIM1_CCER1 0x00
0x00 525C TIM1 capture/compare enable register 1
TIM1_CCER2 0x00
0x00 525D TIM1 capture/compare enable register 2
TIM5_CCER1 0x00
0x00 530A TIM5 capture/compare enable register 1
TIM5_CCER2 0x00
0x00 530B TIM5 capture/compare enable register 2
(1)
Depends on the previous reset source.
(2)
Write only register.
0x00 7F0B to
Reserved area (85 bytes)
0x00 7F5F
0x00 7F78 to
Reserved area (2 bytes)
0x00 7F79
0x00 7F81 to
Reserved area (15 bytes)
0x00 7F8F
(1)
Accessible by debug module only
(1)
Except PA1
8 Option bytes
Option bytes contain configurations for device hardware features as well as the memory
protection of the device. They are stored in a dedicated block of the memory. Except for the
ROP (read-out protection) byte, each option byte has to be stored twice, in a regular form
(OPTx) and a complemented one (NOPTx) for redundancy.
Option bytes can be modified in ICP mode (via SWIM) by accessing the EEPROM address
shown in the table below.
Option bytes can also be modified ‘on the fly’ by the application in IAP mode, except the ROP
option that can only be modified in ICP mode (via SWIM).
Refer to the STM8S Flash programming manual (PM0051) and STM8 SWIM communication
protocol and debug module user manual (UM0470) for information on SWIM programming
procedures.
0x4803 Alternate OPT2 AFR7 AFR6 AFR5 AFR4 AFR3 AFR2 AFR1 AFR0 0x00
function
0x4804 remapping NOPT2 NAFR7 NAFR6 NAFR5 NAFR4 NAFR3 NAFR2 NAFR1 NAFR0 0xFF
(AFR)
0x4805h Miscell. OPT3 Reserved HSI LSI_ EN IWDG WWDG WWDG 0x00
option TRIM _HW _HW _HALT
0x4807 Clock OPT4 Reserved EXT CLK CKAWU PRS C1 PRS C0 0x00
option SEL
OPT0
ROP[7:0] Memory readout protection (ROP)
0xAA: Enable readout protection (write access via SWIM protocol)
OPT1
UBC[7:0] User boot code area
0x00: no UBC, no write-protection
0x01: Page 0 defined as UBC, memory write-protected
0x02: Pages 0 to 1 defined as UBC, memory write-protected.
Page 0 and 1 contain the interrupt vectors.
...
0x7F: Pages 0 to 126 defined as UBC, memory write-protected
Other values: Pages 0 to 127 defined as UBC, memory
write-protected
Note: Refer to the family reference manual (RM0016) section on
Flash write protection for more details.
OPT2
AFR[7:0]
Refer to following section for alternate function remapping decriptions
of bits [7:2] and [1:0] respectively.
OPT3
HSITRIM:High speed internal clock trimming register size
0: 3-bit trimming supported in CLK_HSITRIMR register
1: 4-bit trimming supported in CLK_HSITRIMR register
OPT4
EXTCLK: External clock selection
0: External crystal connected to OSCIN/OSCOUT
1: External clock signal on OSCIN
OPT5
HSECNT[7:0]:HSE crystal oscillator stabilization time
0x00: 2048 HSE cycles
0xB4: 128 HSE cycles
0xD2: 8 HSE cycles
0xE1: 0.5 HSE cycles
Table 13: STM8S903K3 alternate function remapping bits [7:2] for 32-pin packages
(1)
Option byte no. Description
OPT2
AFR7 Alternate function remapping option 7
(2)
0: AFR7 remapping option inactive: Default alternate functions .
1: Port C3 alternate function = TIM1_CH1N; port C4 alternate
function = TIM1_CH2N.
AFR6 Alternate function remapping option 6
(2)
0: AFR6 remapping option inactive: Default alternate function .
1: Port D7 alternate function = TIM1_CH4.
(1)
Option byte no. Description
(1)
Do not use more than one remapping option in the same port.
(2)
Refer to pinout description.
Table 14: STM8S903F3 alternate function remapping bits [7:2] for 20-pin packages
(1)
Option byte no. Description
OPT2
AFR7 Alternate function remapping option 7
(2)
0: AFR7 remapping option inactive: Default alternate functions
1: Port C3 alternate function = TIM1_CH1N; port C4 alternate
function = TIM1_CH2N.
AFR6 Alternate function remapping option 6
Reserved.
AFR5 Alternate function remapping option 5
Reserved.
AFR4 Alternate function remapping option 4
(2)
0: AFR4 remapping option inactive: Default alternate functions .
1: Port B4 alternate function = ADC_ETR; port B5 alternate function
= TIM1_BKIN.
AFR3 Alternate function remapping option 3
(1)
Option byte no. Description
(2)
0: AFR3 remapping option inactive: Default alternate function .
1: Port C3 alternate function = TLI.
AFR2 Alternate function remapping option 2
Reserved.
(1)
Do not use more than one remapping option in the same port.
(2)
Refer to pinout description.
Table 15: STM8S903K3 alternate function remapping bits [1:0] for 32-pin packages
AFR1 option bit AFR0 option bit I/O port Alternate function mapping
value value
0 1 PC5 TIM5_CH1
PC6 TIM1_CH1
PC7 TIM1_CH2
1 0 PA3
SPI_NSS
PD2 TIM5_CH3
PD2 TIM5_CH3
PC5 TIM5_CH1
PC6 TIM1_CH1
PC7 TIM1_CH2
1 1 PC2 TIM1_CH3N
PC1 TIM1_CH2N
PE5 TIM1_CH1N
PA3 UART1_TX
PF4 UART1_RX
(1)
Refer to pinout description.
Table 16: STM8S903F3 alternate function remapping bits [1:0] for 20-pin packages
AFR1 option bit AFR0 option bit I/O port Alternate function mapping
value value
0 1 PC5 TIM5_CH1
PC6 TIM1_CH1
PC7 TIM1_CH2
1 0 PA3
SPI_NSS
PD2 TIM5_CH3
PD2 TIM5_CH3
PC5 TIM5_CH1
PC6 TIM1_CH1
PC7 TIM1_CH2
1 1 PC2 —
PC1 —
PE5 TIM1_CH1N
PA3 UART1_TX
PF4 UART1_RX
(1)
Refer to pinout description.
9 Unique ID
The devices feature a 96-bit unique device identifier which provides a reference number that
is unique for any device and in any context. The 96 bits of the identifier can never be altered
by the user.
The unique device identifier can be read in single bytes and may then be concatenated using
a custom algorithm.
The unique device identifier is ideally suited:
• For use as serial numbers
• For use as security keys to increase the code security in the program memory while using
and combining this unique ID with software cryptograhic primitives and protocols before
programming the internal memory.
• To activate secure boot processes
Table 17: Unique ID registers (96 bits)
Address Content Unique ID bits
description 7 6 5 4 3 2 1 0
0x4865 X co-ordinate U_ID[7:0]
0x486A U_ID[47:40]
0x486B U_ID[55:48]
0x486C U_ID[63:56]
0x486E U_ID[79:72]
0x486F U_ID[87:80]
0x4870 U_ID[95:88]
10 Electrical characteristics
10.1 Parameter conditions
Unless otherwise specified, all voltages are referred to VSS.
STM8 pin
50 pF
STM8 pin
VIN
|VDDx - VDD| - 50
Variations between different power pins
|VSSx - VSS| mV
Variations between all the different ground - 50
pins
(1)
All power (VDD) and ground (VSS) pins must always be connected to the external power supply
(2)
IINJ(PIN) must never be exceeded. This is implicitly insured if VIN maximum is respected. If VIN maximum
cannot be respected, the injection current must be limited externally to the IINJ(PIN) value. A positive
injection is induced by VIN>VDD while a negative injection is induced by VIN<VSS. For true open-drain
pads, there is no positive injection current, and the corresponding VIN maximum must always be respected
(2) 80
IVSS Total current out of VSS ground lines (sink)
IIO 20
Output current sunk by any I/O and control pin
(3) (4)
IINJ(PIN) ±4
Injected current on NRST pin
(5) ±4
Injected current on any other pin
(3)
I INJ(PIN) (5) ± 20
Total injected current (sum of all I/O and control pins)
(1)
Data based on characterization results, not tested in production.
(2)
All power (VDD) and ground (VSS) pins must always be connected to the external supply.
(3)
IINJ(PIN) must never be exceeded. This is implicitly insured if VIN maximum is respected. If VIN maximum
cannot be respected, the injection current must be limited externally to the IINJ(PIN) value. A positive
injection is induced by VIN>VDD while a negative injection is induced by VIN<VSS. For true open-drain
pads, there is no positive injection current, and the corresponding VIN maximum must always be respected
(4)
ADC accuracy vs. negative injection current: Injecting negative current on any of the analog input pins
should be avoided as this significantly reduces the accuracy of the conversion being performed on
another analog input. It is recommended to add a Schottky diode (pin to ground) to standard analog pins
which may potentially inject negative current. Any positive injection current within the limits specified for
IINJ(PIN) and IINJ(PIN) in the I/O port pin characteristics section does not affect the ADC accuracy.
(5)
When several inputs are submitted to a current injection, the maximum IINJ(PIN) is the absolute sum
of the positive and negative injected currents (instantaneous values). These results are based on
characterization with IINJ(PIN) maximum current injection on four I/O port pins of the device.
UFQFPN20 - 198
LQFP32 - 333
UFQFPN32 - 526
SDIP32 - 333
UFQFPN20 - 49
LQFP32 - 83
UFQFPN32 - 132
SDIP32 - 83
(1)
Care should be taken when selecting the capacitor, due to its tolerance, as well as the parameter
dependency on temperature, DC bias and frequency in addition to other factors. The parameter maximum
value must be respected for the full application range.
(2)
This frequency of 1 MHz as a condition for VCAP parameters is given by design of internal regulator
(3)
To calculate PDmax(TA), use the formula PDmax = (TJmax - TA)/ JA (see Thermal characteristics).
f
CPU (MHz)
Functionality
not 16
guaranteed
in this area 12 Functionality guaranteed
@TA-40 to 125 °C
8
4
0
2.95 4.0 5.0 5.5
Supply voltage
(1)
Reset is always generated after a tTEMP delay. The application must ensure that VDD is
still above the minimum ooperating voltage (VDD min) when the tTEMP delay has elapsed.
C
ESR ESL
Rleak
1. ESR is the equivalent series resistance and ESL is the equivalent inductance.
Table 23: Total current consumption with code execution in run mode at VDD = 5 V
Supply current fCPU = fMASTER/128 = HSE user ext. clock (16 MHz) 0.86 -
in run mode, 125 kHz
HSI RC osc. (16 MHz) 0.7 0.87
code executed
from RAM fCPU = fMASTER/128 =
IDD(RUN) HSI RC osc. (16 MHz/8) 0.46 0.58 mA
15.625 kHz
fCPU = fMASTER =
LSI RC osc. (128 kHz) 0.41 0.55
128 kHz
fCPU = fMASTER/128 =
HSI RC osc. (16 MHz) 0.72 0.9
125 kHz
fCPU = fMASTER/128 =
HSI RC osc. (16 MHz/8) 0.46 0.58
15.625 kHz
fCPU = fMASTER =
LSI RC osc. (128 kHz) 0.42 0.57
128 kHz
(1)
Data based on characterization results, not tested in production.
(2)
Default clock configuration measured with all peripherals off.
Table 24: Total current consumption with code execution in run mode at VDD = 3.3 V
Symbol Parameter Conditions Typ (1) Unit
Max
Supply current fCPU = fMASTER/ HSE user ext. clock (16 MHz) 0.81 -
in run mode, 128 = 125 kHz
HSI RC osc. (16 MHz) 0.7 0.87
code executed
from RAM fCPU = fMASTER/
HSI RC osc. (16 MHz/8) 0.46 0.58
128 = 15.625 kHz
fCPU = fMASTER =
LSI RC osc. (128 kHz) 0.41 0.55
128 kHz
IDD(RUN) mA
HSE crystal osc. (16 MHz) 4 -
fCPU = fMASTER =
HSE user ext. clock (16 MHz) 3.9 4.7
16 MHz
HSI RC osc. (16 MHz) 3.7 4.5
Supply current f
CPU = fMASTER = (2)
in run mode, HSI RC osc. (16 MHz/8) 0.84 1.05
code executed 2 MHz
from Flash
fCPU = fMASTER/
HSI RC osc. (16 MHz) 0.72 0.9
128 = 125 kHz
fCPU = fMASTER =
LSI RC osc. (128 kHz) 0.42 0.57
128 kHz
(1)
Data based on characterization results, not tested in production.
(2)
Default clock configuration measured with all peripherals off.
fCPU = fMASTER/128 =
Supply HSI RC osc. (16 MHz) 0.7 0.88
IDD(WFI) current in 125 kHz mA
wait mode
fCPU = fMASTER/128 =
(2)
HSI RC osc. (16 MHz/8) 0.45 0.57
15.625 kHz
fCPU = fMASTER =
LSI RC osc. (128 kHz) 0.4 0.54
128 kHz
(1)
Data based on characterization results, not tested in production.
(2)
Default clock configuration measured with all peripherals off.
HSI RC osc.
0.89 1.1
(16 MHz)
(1)
Data based on characterization results, not tested in production.
(2)
Default clock configuration measured with all peripherals off.
(1)
Data based on characterization results, not tested in production
(2)
Configured by the REGAH bit in the CLK_ICKR register.
(3)
Configured by the AHALT bit in the FLASH_CR1 register.
Table 28: Total current consumption in active halt mode at VDD = 3.3 V
Conditions
Max at Max at
Main
Symbol Parameter Typ 85 °C 125 °C Unit
voltage (3)
Flash mode Clock source (1) (1)
regulator
(2)
(MVR)
Supply current HSE crystal
IDD(AH) in active halt On Operating mode osc. (16 MHz) 550 - - A
mode
LSI RC osc.
IDD(AH) Supply current Operating mode 200 260 290
(128 kHz)
in active halt
mode HSE crystal
IDD(AH) On 970 - -
osc. (16 MHz)
Power-down
mode LSI RC osc. A
IDD(AH) 150 200 230
(128 kHz)
Supply current
IDD(AH) in active halt Operating mode LSI RC osc. 66 80 105
mode
Off Power-down (128 kHz)
IDD(AH) 10 18 35
mode
(1)
Data based on characterization results, not tested in production
(2)
Configured by the REGAH bit in the CLK_ICKR register.
(3)
Configured by the AHALT bit in the FLASH_CR1 register.
(1)
Data based on characterization results, not tested in production
(1)
Data based on characterization results, not tested in production
(1)
Data guaranteed by design, not tested in production.
(2)
tWU(WFI) = 2 x 1/fmaster + 6 x 1/fCPU.
(3)
Measured from interrupt event to interrupt vector fetch.
(4)
Configured by the REGAH bit in the CLK_ICKR register.
(5)
Configured by the AHALT bit in the FLASH_CR1 register.
(6)
Plus 1 LSI clock depending on synchronization.
(1)
Data guaranteed by design, not tested in production.
(2)
Characterized with all I/Os tied to VSS.
(1)
Data based on a differential IDD measurement between reset configuration and timer
counter running at 16 MHz. No IC/OC programmed (no I/O pads toggling). Not tested in
production.
(2)
Data based on a differential IDD measurement between the on-chip peripheral when kept
under reset and not clocked and the on-chip peripheral when clocked and not kept under
reset. No I/O pads toggling. Not tested in production.
(3)
Data based on a differential IDD measurement between reset configuration and continuous
A/D conversions. Not tested in production.
Figure 13: Typ IDD(RUN) vs. fCPU HSE user external clock, VDD = 5 V
Figure 14: Typ IDD(RUN) vs. VDD HSI RC osc, fCPU = 16 MHz
Figure 15: Typ IDD(WFI) vs. VDD HSE user external clock, fCPU = 16 MHz
Figure 16: Typ IDD(WFI) vs. fCPU HSE user external clock, VDD = 5 V
Figure 17: Typ IDD(WFI) vs. VDD HSI RC osc, fCPU = 16 MHz
ILEAK_HSE OSCIN input leakage current VSS < VIN < VDD -1 +1 A
(1)
Data based on characterization results, not tested in production.
V
HSEH
V HSEL
fHSE
External clock
source
OSCIN
STM8
gm Oscillator
5 - - mA/V
transconductance
(4)
tSU(HSE) Startup time VDD is stabilized - 1 - ms
(1)
C is approximately equivalent to 2 x crystal Cload.
(2)
The oscillator selection can be optimized in terms of supply current using a high quality resonator with
small Rm value. Refer to crystal manufacturer for more details
(3)
Data based on characterization results, not tested in production.
(4)
tSU(HSE) is the start-up time measured from the moment it is enabled (by software) to a stabilized 16
MHz oscillation is reached. This value is measured for a standard crystal resonator and it can vary
significantly with the crystal manufacturer.
Rm
f HSE to core
CO
Lm RF
CL1
Cm OSCIN gm
Resonator
Consumption
control
Resonator
CL2 OSCOUT
STM8
(1)
Refer to application note.
(2)
Data based on characterization results, not tested in production.
(3)
Guaranteed by design, not tested in production.
(1)
Minimum supply voltage without losing data stored in RAM (in halt mode or under reset)
or in hardware registers (only in halt mode). Guaranteed by design, not tested in production.
(2)
Refer to the Operating conditions section for the value of VIT-max
(1)
Data based on characterization results, not tested in production.
(2)
The physical granularity of the memory is 4 bytes, so cycling is performed on 4 bytes
even when a write/erase operation addresses a single byte.
General characteristics
Subject to general operating conditions for VDD and TA unless otherwise specified. All unused
pins must be kept at a fixed voltage: using the output mode of the I/O for example or an
external pull-up or pull-down resistor.
Vhys (1)
- 700 - mV
Hysteresis
Load = 50 pF
(3)
Fast I/Os - - 20
Load = 20 pF
(1)
Hysteresis voltage between Schmitt trigger switching levels. Based on characterization results, not
tested in production.
(2)
Data based on characterisation results, not tested in production.
(3)
Data guaranteed by design.
(1)
Data based on characterization results, not tested in production
(1)
Data based on characterization results, not tested in production
IIO = 10 mA,
Output low level with 4 pins sunk - 1.0
(1)
VDD = 3.3 V
VOL
IIO = 20 mA,
Output low level with 4 pins sunk - 1.5
(1)
VDD = 5 V
IIO = 10 mA,
Output high level with 8 pins sourced 4.0 - V
VDD = 5 V
IIO = 10 mA,
VOH Output high level with 4 pins sourced 2.1
(1)
-
VDD = 3.3 V
IIO = 20 mA,
Output high level with 4 pins sourced 3.3
(1)
-
VDD = 5 V
(1)
Data based on characterization results, not tested in production
Figure 28: Typ. VOL @ VDD = 3.3 V (true open drain ports)
Figure 34: Typ. VDD - VOH@ VDD = 3.3 V (high sink ports)
VOL(NRST)
NRST output low
- - 0.5
(1)
level voltage
RPU(NRST)
NRST pull-up
30 55 80 k
(2)
resistor
tI FP(NRST)
NRST input filtered
- - 75
(3)
pulse
ns
tIN FP(NRST)
NRST input not
500 - -
(3)
filtered pulse
tOP(NRST)
NRST output
20 - - s
(3)
pulse
(1)
Data based on characterization results, not tested in production.
(2)
The RPU pull-up equivalent resistor is based on a resistive transistor
(3)
Data guaranteed by design, not tested in production.
The reset network shown in the following figure protects the device against parasitic resets.
The user must ensure that the level on the NRST pin can go below VIL(NRST) max. (see Table
40: I/O static characteristics ), otherwise the reset is not taken into account internally.
For power consumption sensitive applications, the external reset capacitor value can be
reduced to limit the charge/discharge current. If NRST signal is used to reset external circuitry,
attention must be taken to the charge/discharge time of the external capacitor to fulfill the
external devices reset timing conditions. Minimum recommended capacity is 100 nF.
VDD STM8
RPU
External
NRST Filter Internal reset
reset
circuit
0.1 μF
(optional)
(1)
Parameters are given by selecting 10 MHz I/O output frequency.
(2)
Data characterization in progress.
(3)
Values based on design simulation and/or characterization results, and not tested in
production.
(4)
Min time is for the minimum time to drive the output and the max time is for the maximum
time to validate the data.
(5)
Min time is for the minimum time to invalidate the output and the max time is for the
maximum time to put the data in Hi-Z.
NSS input
tSU(NSS) tc(SCK) th(NSS)
CPHA= 0
SCK Input
CPOL=0
tw(SCKH)
CPHA= 0 tw(SCKL)
CPOL=1
NSS input
tSU(NSS) tc(SCK) th(NSS)
CPHA=1
SCK Input
CPOL=0
tw(SCKH)
CPHA=1 tw(SCKL)
CPOL=1
ai14135
1. Measurement points are made at CMOS levels: 0.3 VDD and 0.7 VDD.
(1)
Figure 41: SPI timing diagram - master mode
High
NSS input
SCK output tc(SCK)
CPHA= 0
CPOL=0
CPHA= 0
CPOL=1
SCK output
CPHA=1
CPOL=0
CPHA=1
CPOL=1
tw(SCKH) tr(SCK)
tsu(MI) tw(SCKL) tf(SCK)
MISO
INP UT MS BIN BI T6 IN LSB IN
th(MI)
MOSI
M SB OUT B I T1 OUT LSB OUT
OUTUT
tv(MO) th(MO)
ai14136b
1. Measurement points are made at CMOS levels: 0.3 VDD and 0.7 VDD.
2
10.3.9 I C interface characteristics
2
Table 46: I C characteristics
Symbol Parameter 2 2 (1) Unit
Standard mode I C Fast mode I C
tr(SDA)
SDA and SCL rise time - 1000 - 300 ns
tr(SCL)
tf(SDA)
SDA and SCL fall time - 300 - 300
tf(SCL)
(1) 2
fMASTER, must be at least 8 MHz to achieve max fast I C speed (400kHz)
(2) 2
Data based on standard I C protocol requirement, not tested in production
(3)
The maximum hold time of the start condition has only to be met if the interface does not stretch the
low time
(4)
The device must internally provide a hold time of at least 300 ns for the SDA signal in order to bridge
the undefined region of the falling edge of SCL
2
Figure 42: Typical application with I C bus and timing diagram
VDD VDD
4.7kΩ 4.7kΩ
STM8S
100Ω SDA
REPEATED
START
START
tsu(STA) tw(STO:STA)
SDA
START
ai17490
1. Measurement points are made at CMOS levels: 0.3 x VDD and 0.7 x VDD.
VBGREF Internal bandgap reference VDD =2.95 to 5.5 V 1.19 1.22 1.25 V
voltage
14 1/fADC
(1)
During the sample time the input capacitance CAIN (3 pF max) can be charged/discharged
by the external source. The internal resistance of the analog source must allow the
capacitance to reach its final voltage level within tS. After the end of the sample time tS,
changes of the analog input voltage have no effect on the conversion result. Values for the
sample clock tS depend on programming.
(1)
Symbol Parameter Conditions Typ Max Unit
(1)
Data based on characterisation results, not tested in production.
(2)
ADC accuracy vs. negative injection current: Injecting negative current on any of the
analog input pins should be avoided as this significantly reduces the accuracy of the
conversion being performed on another analog input. It is recommended to add a Schottky
diode (pin to ground) to standard analog pins which may potentially inject negative current.
Any positive injection current within the limits specified for IINJ(PIN) and IINJ(PIN) in the I/O
port pin characteristics section does not affect the ADC accuracy.
Table 49: ADC accuracy with RAIN < 10 k RAIN, VDD = 3.3 V
(1)
Symbol Parameter Conditions Typ Max Unit
fADC = 4 MHz 2 3
(1)
Data based on characterisation results, not tested in production.
VDD STM8
VT
VAIN RAIN 0.6 V
AINx 10-bit A/D
conversion
VT IL
CAIN CADC
0.6 V ± 1 µA
A device reset allows normal operations to be resumed. The test results are given in the table
below based on the EMS levels and classes defined in application note AN1709 (EMC design
guide for STMicrocontrollers).
Prequalification trials
Most of the common failures (unexpected reset and program counter corruption) can be
recovered by applying a low state on the NRST pin or the oscillator pins for 1 second.
To complete these trials, ESD stress can be applied directly on the device, over the range of
specification values. When unexpected behavior is detected, the software can be hardened
to prevent unrecoverable errors occurring. See application note AN1015 (Software techniques
for improving microcontroller EMC performance).
(1)
Data obtained with HSI clock configuration, after applying HW recommendations described
in AN2860 (EMC guidelines for STM8S microcontrollers).
Conditions
(1)
Max fHSE/fCPU
Symbol Parameter Unit
General Monitored
conditions frequency band 16 MHz/ 16 MHz/
8 MHz 16 MHz
SAE EMI
SAE EMI level 2.5 2.5
level
(1)
Data based on characterisation results, not tested in production.
Human body model. This test conforms to the JESD22-A114A/A115A standard. For more
details, refer to the application note AN1181.
VESD(HBM)
Electrostatic discharge TA = 25°C, conforming to
voltage JESD22-A114 A 4000
(Human body model)
V
VESD(CDM)
Electrostatic discharge TA LQFP32 package =
voltage 25°C, conforming to IV 1000
(Charge device model) SD22-C101
(1)
Data based on characterization results, not tested in production
This test conforms to the EIA/JESD 78 IC latch-up standard. For more details, refer to the
application note AN1181.
TA = 85 °C A
TA = 125 °C A
(1)
Class description: A Class is an STMicroelectronics internal specification. All its limits
are higher than the JEDEC specifications, that means when a device belongs to class A it
exceeds the JEDEC standard. B class strictly covers all the JEDEC criteria (international
standard).
11 Package information
In order to meet environmental requirements, ST offers these devices in different grades of
® ®
ECOPACK packages, depending on their level of environmental compliance. ECOPACK
®
specifications, grade definitions and product status are available at: www.st.com. ECOPACK
is an ST trademark.
ccc C
D
D1
D3 A
A2
24 17
16
25 L1
b
E3 E1 E
32
9
L
Pin 1 A1 K
identification 1 8 c
5V_ME
Table 54: 32-pin low profile quad flat package mechanical data
(1)
Dim. mm inches
A 1.600 0.0630
(1)
Dim. mm inches
D3 5.600 0.2205
E3 5.600 0.2205
e 0.800 0.0315
L1 1.000 0.0394
(1)
Values in inches are converted from mm and rounded to 4 decimal digits
AOB8_ME
Table 55: 32-lead, ultra thin, fine pitch quad flat no-lead package mechanical data
(1)
Dim. mm inches
A3 0.200 0.0079
(1)
Dim. mm inches
e 0.500 0.0197
(1)
Values in inches are converted from mm and rounded to 4 decimal digits.
Pin 1 E
TOP VIEW
L1
D ddd
L4
e
10 A3
L2
5 11 e
b
E
1 15
20 16
L3 A1
A
BOTTOM VIEW
SIDE VIEW
103_A0A5_ME
Table 56: 20-lead, ultra thin, fine pitch quad flat no-lead package (3 x 3) package
mechanical data
(1)
Dim. mm inches
Min Typ Max Min Typ Max
D 3.000 0.1181
E 3.000 0.1181
A3 0.152 0.0060
e 0.500 0.0197
L3 0.150 0.0059
L4 0.200 0.0079
(1)
Values in inches are converted from mm and rounded to 4 decimal digits.
0.5mm
0.8mm
[0.032"]
4mm
[0.157"]
0.5mm
4mm [0.157"]
ai15319
Bottom view
E1
A2 A
A1 L
B1 B e
C eA
eB
32 17
1 16
76_ME
Table 57: 32-lead shrink plastic DIP (400 ml) package mechanical data
(1)
Dim. mm inches
A1 0.508 0.0200
e 1.778 0.0700
eA 10.160 0.4000
eB 12.700 0.5000
(1)
Values in inches are converted from mm and rounded to 4 decimal digits
20 11
c
E1 E
1 10
aaa CP
A1 L
A A2
L1
b e
YA_ME
A 1.200 0.0472
e 0.650 0.0256
L1 1.000 0.0394
(1)
Dim. mm inches
(1)
Values in inches are converted from mm and rounded to 4 decimal digits
D
20 11 h x 45°
C
E H
1 10
ddd
B e A1
A1 k L
Z7_ME
Table 59: 20-lead, plastic small outline (300 mils) mechanical data
(1)
Dim. mm inches
e 1.270 0.0500
(1)
Dim. mm inches
(1)
Values in inches are converted from mm and rounded to 4 decimal digits
Where:
• TAmax is the maximum ambient temperature in °C
• is the package junction-to-ambient thermal resistance in °C/W
JA
• Ppower. is the product of I andV , expressed in Watts. This is the maximum chip internal
INTmax DD DD
Where:
PI/Omax = (VOL*IOL) + ((VDD-VOH)*IOH), taking into account the actual VOL/IOL and VOH/IOH
of the I/Os at low and high level in the application.
JA 110
Thermal resistance junction-ambient °C/W
TSSOP20 - 4 x 4 mm
JA 20
Thermal resistance junction-ambient °C/W
SO20W - 300 mils
(1)
Symbol Parameter Value Unit
JA 101
Thermal resistance junction-ambient °C/W
UFQFPN20 - 3 x 3 mm
JA 60
Thermal resistance junction-ambient °C/W
LQFP32 - 7 x 7 mm
JA 38 °C/W
Thermal resistance junction-ambient
UFQFPN32 - 5 x 5 mm
JA 60 °C/W
Thermal resistance junction-ambient
SDIP32 - 400 mils
(1)
Thermal resistances are based on JEDEC JESD51-2 with 4-layer PCB in a natural
convection environment.
• Maximum 20 I/Os used at the same time in output at low level with
IOL = 8 mA, VOL= 0.4 V
PINTmax = 8 mA x 5 V = 400 mW
Amax
• PDmax = 400 mW + 64 mW
Thus: PDmax = 464 mW
TJmax for LQFP32 can be calculated as follows, using the thermal resistance JA:
12 Ordering information
Figure 53: STM8S903K3/F3 ordering information scheme
Product class
STM8 microcontroller
Family type
S = Standard
Sub-family type
903 = 903 sub-family
Pin count
K = 32 pins
F = 20 pins
Package type 1
B = SDIP
T = LQFP
U = UFQFPN
P = TSSOP
M = SO
Temperature range
3 = -40 °C to 125 °C
6 = -40 °C to 85 °C
Package pitch
Blank = 0.5 or 0.65 mm (2)
C = 0.8 mm (3)
Packing
No character = Tray or tube
TR = Tape and reel
1. A dedicated ordering information scheme will be released if, in the future, memory
programming service (FastROM) is required. The letter "P" will be added after STM8S.
Three unique letters identifying the customer application code will also be visible in the
codification. Example: STM8SP903K3MACTR.
2. UFQFPN, TSSOP, and SO packages.
3. LQFP package.
For a list of available options (e.g. memory size, package) and orderable part numbers or for
further information on any aspect of this device, please go to www.st.com or contact the ST
Sales Office nearest to you.
Customer ...........................................................................................................
Address ...........................................................................................................
Contact ...........................................................................................................
TSSOP20 [ ] STM8S903F3
SO20 [ ] STM8S903F3
UFQFPN20 [ ] STM8S903F3
LQFP32 [ ] STM8S903K3
UFQFPN32 [ ] STM8S903K3
Temperature range
[ ] -40°C to +85°C or [ ] -40°C to +125°C
Padding value for unused program memory (check only one option)
UBC bit1
[ ] 0: Reset
[ ] 1: Set
UBC bit2
[ ] 0: Reset
[ ] 1: Set
UBC bit3
[ ] 0: Reset
[ ] 1: Set
UBC bit4
[ ] 0: Reset
[ ] 1: Set
UBC bit5
[ ] 0: Reset
[ ] 1: Set
UBC bit6
[ ] 0: Reset
[ ] 1: Set
UBC bit7
[ ] 0: Reset
[ ] 1: Set
Note: If the UBC area is not used, please select all bits at reset states.
AFR1, AFR0
[ ] 00: Remapping options inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 01: Port C5 alternate function = TIM5_CH1, port
C6 alternate function = TIM1_CH1, and port C7
alternate function = TIM1_CH2.
[ ] 10: Port A3 alternate function = SPI_NSS and
port D2 alternate function = TIM5_CH3.
[ ] 11: Port D2 alternate function = TIM5_CH3, port
C5 alternate function = TIM5_CH1, port C6
alternate function = TIM1_CH1, port C7 alternate
function = TIM1_CH2, port C2 alternate function =
TIM1_CH3N, port C1 alternate function =
TIM1_CH2N, port E5 alternate function =
TIM1_CH1N, port A3 alternate function =
UART1_TX, and port F4 alternate function =
UART1_RX.
AFR2
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port C4 alternate function = AIN2, port D2
alternate function = AIN3, port D4 alternate function
= UART1_CK.
AFR3
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port C3 alternate function = TLI.
AFR4
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port B4 alternate function = ADC_ETR, port
B5 alternate function = TIM1_BKIN.
AFR5
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port D0 alternate function = CLK_CCO.
AFR6
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port D7 alternate function = TIM1_CH4.
AFR7
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port C3 alternate function = TIM1_CH1N, port
C4 alternate function = TIM1_CH2N.
AFR2
Reserved
AFR3
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port C3 alternate function = TLI.
AFR4
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port B4 alternate function = ADC_ETR, port
B5 alternate function = TIM1_BKIN.
AFR5
Reserved
AFR6
Reserved
AFR7
[ ] 0: Remapping option inactive. Default alternate
(check only one option) functions used. Refer to pinout description.
[ ] 1: Port C3 alternate function = TIM1_CH1N, port
C4 alternate function = TIM1_CH2N.
OPT3 watchdog
WWDG_HALT
[ ] 0: No reset generated on halt if WWDG active
(check only one option)
[ ] 1: Reset generated on halt if WWDG active
WWDG_HW
[ ] 0: WWDG activated by software
(check only one option)
[ ] 1: WWDG activated by hardware
IWDG_HW
[ ] 0: IWDG activated by software
(check only one option)
[ ] 1: IWDG activated by hardware
LSI_EN
[ ] 0: LSI clock is not available as CPU clock source
(check only one option)
[ ] 1: LSI clock is available as CPU clock source
HSITRIM
[ ] 0: 3-bit trimming supported in CLK_HSITRIMR register
(check only one option)
[ ] 1: 4-bit trimming supported in CLK_HSITRIMR register
OPT4 wakeup
PRSC
[ ] for 16 MHz to 128 kHz prescaler
(check only one option)
[ ] for 8 MHz to 128 kHz prescaler
[ ] for 4 MHz to 128 kHz prescaler
CKAWUSEL
[ ] LSI clock source selected for AWU
(check only one option)
[ ] HSE clock with prescaler selected as clock source for for
AWU
EXTCLK
[ ] External crystal connected to OSCIN/OSCOUT
(check only one option)
[ ] External clock signal on OSCIN
OPT6 is reserved
Comments: ...........................................................................................................
Notes: ...........................................................................................................
14 Revision history
Table 61: Document revision history
28-Jul-2011 6
Added note for OPT1 option list.
Updated OPT2 option list for STM8S903K3 and created OPT2
option list for STM8S903F3 in STM8S903K3/F3 FASTROM
microcontroller option list.
Updated UART1 interrupt vector addresses in table Table 10:
Interrupt mapping
Updated note related to true open-drain outputs in Table 5:
TSSOP20/SO20/UFQFPN20 pin description and Table 5:
TSSOP20/SO20/UFQFPN20 pin description.
Added UFQFPN20 package.
Remove CLK_CANCCR register from Table 8: General
hardware register map .
Added note for Px_IDR registers in Table 7: I/O port hardware
register map.
Updated title of Ordering information.
Removed Typical HSI accuracy curve in High speed internal
RC oscillator (HSI).
Updated value of recommended external capacitor to 100 nF
inReset pin characteristics.
Updated disclaimer.
04-Apr-2012 7
Internal reference voltage renamed internal bandgap reference
voltage.
Updated notes related to VCAP in Table 21: General operating
conditions.
Added values of tR/tF for 50 pF load capacitance, and updated
note in Table 40: I/O static characteristics.
Updated typical and maximum values of RPU in Table 40: I/O
static characteristics and Table 44: NRST pin characteristics.
Changed SCK input to SCK output in SPI serial peripheral
interface
Modified Figure 47: 20-lead, ultra thin, fine pitch quad flat
no-lead package outline (3 x 3)to add package top view.
13-Jun-2012 8
Restored Figure 44: Typical application with ADC
Modified Figure 47: 20-lead, ultra thin, fine pitch quad flat
no-lead package outline (3 x 3) to add package top view.
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries
(“ST”) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products
and services described herein at anytime, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein,
and ST assumes no liability whatsoever relating to the choice, selection or use of the ST products and services described
herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document.
If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for
the use of such third party products or services, or any intellectual property contained therein or considered as a warranty
covering the use in any manner whatsoever of such third party products or services or any intellectual property contained
therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS
OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT
LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND
THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT,
COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document
shall immediately voidany warranty granted by ST for the ST product or service described herein and shall not create or
extend in any manner whatsoever, any liability of ST.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.
Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel
- Italy - Japan - Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom -
United States of America
www.st.com