STM8S Series And STM8AF 8 Bit Microcontrollers STM8 Reference Manual
User Manual:
Open the PDF directly: View PDF
Page Count: 467 [warning: Documents this large are best viewed by clicking the View PDF Link!]
- 1 Central processing unit (CPU)
- 2 Boot ROM
- 3 Memory and register map
- 4 Flash program memory and data EEPROM
- 4.1 Flash and EEPROM introduction
- 4.2 Flash and EEPROM glossary
- 4.3 Main Flash memory features
- 4.4 Memory organization
- 4.5 Memory protection
- 4.6 Memory programming
- 4.7 ICP (in-circuit programming) and IAP (in-application programming)
- 4.8 Flash registers
- 4.8.1 Flash control register 1 (FLASH_CR1)
- 4.8.2 Flash control register 2 (FLASH_CR2)
- 4.8.3 Flash complementary control register 2 (FLASH_NCR2)
- 4.8.4 Flash protection register (FLASH_FPR)
- 4.8.5 Flash protection register (FLASH_NFPR)
- 4.8.6 Flash program memory unprotecting key register (FLASH_PUKR)
- 4.8.7 Data EEPROM unprotection key register (FLASH_DUKR)
- 4.8.8 Flash status register (FLASH_IAPSR)
- 4.8.9 Flash register map and reset values
- 5 Single wire interface module (SWIM) and debug module (DM)
- 6 Interrupt controller (ITC)
- 7 Power supply
- 8 Reset (RST)
- 9 Clock control (CLK)
- Figure 20. Clock tree
- 9.1 Master clock sources
- 9.2 Master clock switching
- 9.3 Low-speed clock selection
- 9.4 CPU clock-divider
- 9.5 Peripheral clock-gating (PCG)
- 9.6 Clock security system (CSS)
- 9.7 Clock-out capability (CCO)
- 9.8 CLK interrupts
- 9.9 CLK register description
- 9.9.1 Internal clock register (CLK_ICKR)
- 9.9.2 External clock register (CLK_ECKR)
- 9.9.3 Clock master status register (CLK_CMSR)
- 9.9.4 Clock master switch register (CLK_SWR)
- 9.9.5 Switch control register (CLK_SWCR)
- 9.9.6 Clock divider register (CLK_CKDIVR)
- 9.9.7 Peripheral clock gating register 1 (CLK_PCKENR1)
- 9.9.8 Peripheral clock gating register 2 (CLK_PCKENR2)
- 9.9.9 Clock security system register (CLK_CSSR)
- 9.9.10 Configurable clock output register (CLK_CCOR)
- 9.9.11 HSI clock calibration trimming register (CLK_HSITRIMR)
- 9.9.12 SWIM clock control register (CLK_SWIMCCR)
- 9.10 CLK register map and reset values
- 10 Power management
- 11 General purpose I/O ports (GPIO)
- 12 Auto-wakeup (AWU)
- 13 Beeper (BEEP)
- 14 Independent watchdog (IWDG)
- 15 Window watchdog (WWDG)
- 15.1 WWDG introduction
- 15.2 WWDG main features
- 15.3 WWDG functional description
- 15.4 How to program the watchdog timeout
- 15.5 WWDG low power modes
- 15.6 Hardware watchdog option
- 15.7 Using Halt mode with the WWDG (WWDGHALT option)
- 15.8 WWDG interrupts
- 15.9 WWDG registers
- 15.10 Window watchdog register map and reset values
- 16 Timer overview
- 17 16-bit advanced control timer (TIM1)
- 17.1 TIM1 introduction
- 17.2 TIM1 main features
- 17.3 TIM1 time base unit
- 17.4 TIM1 clock/trigger controller
- Figure 43. Clock/trigger controller block diagram
- 17.4.1 Prescaler clock (CK_PSC)
- 17.4.2 Internal clock source (fMASTER)
- 17.4.3 External clock source mode 1
- 17.4.4 External clock source mode 2
- 17.4.5 Trigger synchronization
- 17.4.6 Synchronization between TIM1, TIM5 and TIM6 timers
- Figure 53. Timer chaining system implementation example
- Figure 54. Trigger/master mode selection blocks
- Figure 55. Master/slave timer example
- Figure 56. Gating timer B with OC1REF of timer A
- Figure 57. Gating timer B with the counter enable signal of timer A (CNT_EN)
- Figure 58. Triggering timer B with the UEV of timer A (TIMERA-UEV)
- Figure 59. Triggering timer B with counter enable CNT_EN of timer A
- Figure 60. Triggering Timer A and B with Timer A TI1 input
- 17.5 TIM1 capture/compare channels
- Figure 61. Capture/compare channel 1 main circuit
- Figure 62. 16-bit read sequence for the TIM1_CCRi register in capture mode
- 17.5.1 Write sequence for 16-bit TIM1_CCRi registers
- 17.5.2 Input stage
- 17.5.3 Input capture mode
- 17.5.4 Output stage
- 17.5.5 Forced output mode
- 17.5.6 Output compare mode
- 17.5.7 PWM mode
- Figure 70. Edge-aligned counting mode PWM mode 1 waveforms (ARR = 8)
- Figure 71. Center-aligned PWM waveforms (ARR = 8)
- Figure 72. Example of one-pulse mode
- Figure 73. Complementary output with deadtime insertion
- Figure 74. Deadtime waveforms with a delay greater than the negative pulse
- Figure 75. Deadtime waveforms with a delay greater than the positive pulse
- Figure 76. Six-step generation, COM example (OSSR = 1)
- 17.5.8 Using the break function
- 17.5.9 Clearing the OCiREF signal on an external event
- 17.5.10 Encoder interface mode
- 17.6 TIM1 interrupts
- 17.7 TIM1 registers
- 17.7.1 Control register 1 (TIM1_CR1)
- 17.7.2 Control register 2 (TIM1_CR2)
- 17.7.3 Slave mode control register (TIM1_SMCR)
- 17.7.4 External trigger register (TIM1_ETR)
- 17.7.5 Interrupt enable register (TIM1_IER)
- 17.7.6 Status register 1 (TIM1_SR1)
- 17.7.7 Status register 2 (TIM1_SR2)
- 17.7.8 Event generation register (TIM1_EGR)
- 17.7.9 Capture/compare mode register 1 (TIM1_CCMR1)
- 17.7.10 Capture/compare mode register 2 (TIM1_CCMR2)
- 17.7.11 Capture/compare mode register 3 (TIM1_CCMR3)
- 17.7.12 Capture/compare mode register 4 (TIM1_CCMR4)
- 17.7.13 Capture/compare enable register 1 (TIM1_CCER1)
- 17.7.14 Capture/compare enable register 2 (TIM1_CCER2)
- 17.7.15 Counter high (TIM1_CNTRH)
- 17.7.16 Counter low (TIM1_CNTRL)
- 17.7.17 Prescaler high (TIM1_PSCRH)
- 17.7.18 Prescaler low (TIM1_PSCRL)
- 17.7.19 Auto-reload register high (TIM1_ARRH)
- 17.7.20 Auto-reload register low (TIM1_ARRL)
- 17.7.21 Repetition counter register (TIM1_RCR)
- 17.7.22 Capture/compare register 1 high (TIM1_CCR1H)
- 17.7.23 Capture/compare register 1 low (TIM1_CCR1L)
- 17.7.24 Capture/compare register 2 high (TIM1_CCR2H)
- 17.7.25 Capture/compare register 2 low (TIM1_CCR2L)
- 17.7.26 Capture/compare register 3 high (TIM1_CCR3H)
- 17.7.27 Capture/compare register 3 low (TIM1_CCR3L)
- 17.7.28 Capture/compare register 4 high (TIM1_CCR4H)
- 17.7.29 Capture/compare register 4 low (TIM1_CCR4L)
- 17.7.30 Break register (TIM1_BKR)
- 17.7.31 Deadtime register (TIM1_DTR)
- 17.7.32 Output idle state register (TIM1_OISR)
- 17.7.33 TIM1 register map and reset values
- 18 16-bit general purpose timers (TIM2, TIM3, TIM5)
- 18.1 TIM2, TIM3 and TIM5 introduction
- 18.2 TIM2/TIM3 main features
- 18.3 TIM5 main features
- 18.4 TIM2/TIM3/TIM5 functional description
- 18.5 TIM2/TIM3/TIM5 interrupts
- 18.6 TIM2/TIM3/TIM5 registers
- 18.6.1 Control register 1 (TIMx_CR1)
- 18.6.2 Control register 2 (TIM5_CR2)
- 18.6.3 Slave mode control register (TIM5_SMCR)
- 18.6.4 Interrupt enable register (TIMx_IER)
- 18.6.5 Status register 1 (TIMx_SR1)
- 18.6.6 Status register 2 (TIMx_SR2)
- 18.6.7 Event generation register (TIMx_EGR)
- 18.6.8 Capture/compare mode register 1 (TIMx_CCMR1)
- 18.6.9 Capture/compare mode register 2 (TIMx_CCMR2)
- 18.6.10 Capture/compare mode register 3 (TIMx_CCMR3)
- 18.6.11 Capture/compare enable register 1 (TIMx_CCER1)
- 18.6.12 Capture/compare enable register 2 (TIMx_CCER2)
- 18.6.13 Counter high (TIMx_CNTRH)
- 18.6.14 Counter low (TIMx_CNTRL)
- 18.6.15 Prescaler register (TIMx_PSCR)
- 18.6.16 Auto-reload register high (TIMx_ARRH)
- 18.6.17 Auto-reload register low (TIMx_ARRL)
- 18.6.18 Capture/compare register 1 high (TIMx_CCR1H)
- 18.6.19 Capture/compare register 1 low (TIMx_CCR1L)
- 18.6.20 Capture/compare register 2 high (TIMx_CCR2H)
- 18.6.21 Capture/compare register 2 low (TIMx_CCR2L)
- 18.6.22 Capture/compare register 3 high (TIMx_CCR3H)
- 18.6.23 Capture/compare register 3 low (TIMx_CCR3L)
- 19 8-bit basic timer (TIM4, TIM6)
- 19.1 TIM4, TIM6 introduction
- 19.2 TIM4 main features
- 19.3 TIM6 main features
- 19.4 TIM4/TIM6 interrupts
- 19.5 TIM4/TIM6 clock selection
- 19.6 TIM4/TIM6 registers
- 19.6.1 Control register 1 (TIMx_CR1)
- 19.6.2 Control register 2 (TIM6_CR2)
- 19.6.3 Slave mode control register (TIM6_SMCR)
- 19.6.4 Interrupt enable register (TIMx_IER)
- 19.6.5 Status register 1 (TIMx_SR)
- 19.6.6 Event generation register (TIMx_EGR)
- 19.6.7 Counter (TIMx_CNTR)
- 19.6.8 Prescaler register (TIMx_PSCR)
- 19.6.9 Auto-reload register (TIMx_ARR)
- 19.6.10 TIM4/TIM6 register map and reset values
- 20 Serial peripheral interface (SPI)
- 20.1 SPI introduction
- 20.2 SPI main features
- 20.3 SPI functional description
- 20.3.1 SPI general description
- 20.3.2 Configuring the SPI in slave mode
- 20.3.3 Configuring the SPI master mode
- 20.3.4 Configuring the SPI for simplex communications
- 20.3.5 Data transmission and reception procedures
- Figure 94. TXE/RXNE/BSY behavior in full duplex mode (RXONLY = 0). Case of continuous transfers
- Figure 95. TXE/RXNE/BSY behavior in slave / full duplex mode (BDM = 0, RXONLY = 0). Case of continuous transfers
- Figure 96. TXE/BSY in master transmit-only mode (BDM = 0 and RXONLY = 0). Case of continuous transfers
- Figure 97. TXE/BSY in slave transmit-only mode (BDM = 0 and RXONLY = 0). Case of continuous transfers
- Figure 98. RXNE behavior in receive-only mode (BDM = 0 and RXONLY = 1). Case of continuous transfers
- Figure 99. TXE/BSY behavior when transmitting (BDM = 0 and RXLONY = 0). Case of discontinuous transfers
- 20.3.6 CRC calculation
- 20.3.7 Status flags
- 20.3.8 Disabling the SPI
- 20.3.9 Error flags
- 20.3.10 SPI low power modes
- 20.3.11 SPI interrupts
- 20.4 SPI registers
- 20.4.1 SPI control register 1 (SPI_CR1)
- 20.4.2 SPI control register 2 (SPI_CR2)
- 20.4.3 SPI interrupt control register (SPI_ICR)
- 20.4.4 SPI status register (SPI_SR)
- 20.4.5 SPI data register (SPI_DR)
- 20.4.6 SPI CRC polynomial register (SPI_CRCPR)
- 20.4.7 SPI Rx CRC register (SPI_RXCRCR)
- 20.4.8 SPI Tx CRC register (SPI_TXCRCR)
- 20.5 SPI register map and reset values
- 21 Inter-integrated circuit (I2C) interface
- 21.1 I2C introduction
- 21.2 I2C main features
- 21.3 I2C general description
- 21.4 I2C functional description
- 21.4.1 I2C slave mode
- 21.4.2 I2C master mode
- Figure 104. Transfer sequence diagram for master transmitter
- Figure 105. Method 1: transfer sequence diagram for master receiver
- Figure 106. Method 2: transfer sequence diagram for master receiver when N >2
- Figure 107. Method 2: transfer sequence diagram for master receiver when N=2
- Figure 108. Method 2: transfer sequence diagram for master receiver when N=1
- 21.4.3 Error conditions
- 21.4.4 SDA/SCL line control
- 21.5 I2C low power modes
- 21.6 I2C interrupts
- 21.7 I2C registers
- 21.7.1 Control register 1 (I2C_CR1)
- 21.7.2 Control register 2 (I2C_CR2)
- 21.7.3 Frequency register (I2C_FREQR)
- 21.7.4 Own address register LSB (I2C_OARL)
- 21.7.5 Own address register MSB (I2C_OARH)
- 21.7.6 Data register (I2C_DR)
- 21.7.7 Status register 1 (I2C_SR1)
- 21.7.8 Status register 2 (I2C_SR2)
- 21.7.9 Status register 3 (I2C_SR3)
- 21.7.10 Interrupt register (I2C_ITR)
- 21.7.11 Clock control register low (I2C_CCRL)
- 21.7.12 Clock control register high (I2C_CCRH)
- 21.7.13 TRISE register (I2C_TRISER)
- 21.7.14 I2C register map and reset values
- 22 Universal asynchronous receiver transmitter (UART)
- 22.1 Introduction
- 22.2 UART main features
- 22.3 UART functional description
- Figure 110. UART1 block diagram
- Figure 111. UART2 block diagram
- Figure 112. UART3 block diagram
- Figure 113. UART4 block diagram
- 22.3.1 UART character description
- 22.3.2 Transmitter
- 22.3.3 Receiver
- 22.3.4 High precision baud rate generator
- 22.3.5 Clock deviation tolerance of the UART receiver
- 22.3.6 Parity control
- 22.3.7 Multi-processor communication
- 22.3.8 LIN (local interconnection network) mode
- 22.3.9 UART synchronous communication
- 22.3.10 Single wire half duplex communication
- 22.3.11 Smartcard
- 22.3.12 IrDA SIR ENDEC block
- 22.4 LIN mode functional description
- 22.5 UART low power modes
- 22.6 UART interrupts
- 22.7 UART registers
- 22.7.1 Status register (UART_SR)
- 22.7.2 Data register (UART_DR)
- 22.7.3 Baud rate register 1 (UART_BRR1)
- 22.7.4 Baud rate register 2 (UART_BRR2)
- 22.7.5 Control register 1 (UART_CR1)
- 22.7.6 Control register 2 (UART_CR2)
- 22.7.7 Control register 3 (UART_CR3)
- 22.7.8 Control register 4 (UART_CR4)
- 22.7.9 Control register 5 (UART_CR5)
- 22.7.10 Control register 6 (UART_CR6)
- 22.7.11 Guard time register (UART_GTR)
- 22.7.12 Prescaler register (UART_PSCR)
- 22.7.13 UART register map and reset values
- 23 Controller area network (beCAN)
- 23.1 Introduction
- 23.2 beCAN main features
- 23.3 beCAN general description
- 23.4 Operating modes
- 23.5 Test modes
- 23.6 Functional description
- 23.6.1 Transmission handling
- 23.6.2 Reception handling
- 23.6.3 Identifier filtering
- Figure 148. 32-bit filter bank configuration (FSCx bits = 0b11 in CAN_FCRx register)
- Figure 149. 16-bit filter bank configuration (FSCx bits = 0b10 in CAN_FCRx register)
- Figure 150. 16/8-bit filter bank configuration (FSCx bits = 0b01 in CAN_FCRx register)
- Figure 151. 8-bit filter bank configuration (FSCx bits = 0b00 in CAN_FCRx register)
- Table 65. Example of filter numbering
- Figure 152. Filter banks configured as in the example in Table 65
- 23.6.4 Message storage
- 23.6.5 Error management
- 23.6.6 Bit timing
- 23.7 Interrupts
- 23.8 Register access protection
- 23.9 Clock system
- 23.10 beCAN low power modes
- 23.11 beCAN registers
- 23.11.1 CAN master control register (CAN_MCR)
- 23.11.2 CAN master status register (CAN_MSR)
- 23.11.3 CAN transmit status register (CAN_TSR)
- 23.11.4 CAN transmit priority register (CAN_TPR)
- 23.11.5 CAN receive FIFO register (CAN_RFR)
- 23.11.6 CAN interrupt enable register (CAN_IER)
- 23.11.7 CAN diagnostic register (CAN_DGR)
- 23.11.8 CAN page select register (CAN_PSR)
- 23.11.9 CAN error status register (CAN_ESR)
- 23.11.10 CAN error interrupt enable register (CAN_EIER)
- 23.11.11 CAN transmit error counter register (CAN_TECR)
- 23.11.12 CAN receive error counter register (CAN_RECR)
- 23.11.13 CAN bit timing register 1 (CAN_BTR1)
- 23.11.14 CAN bit timing register 2 (CAN_BTR2)
- 23.11.15 Mailbox registers
- 23.11.16 CAN filter registers
- 23.12 CAN register map
- 24 Analog/digital converter (ADC)
- 24.1 Introduction
- 24.2 ADC main features
- 24.3 ADC extended features
- 24.4 ADC pins
- 24.5 ADC functional description
- 24.6 ADC low power modes
- 24.7 ADC interrupts
- 24.8 Data alignment
- 24.9 Reading the conversion result
- 24.10 Schmitt trigger disable registers
- 24.11 ADC registers
- 24.11.1 ADC data buffer register x high (ADC_DBxRH) (x=0..7 or 0..9 )
- 24.11.2 ADC data buffer register x low (ADC_DBxRL) (x=or 0..7 or 0..9)
- 24.11.3 ADC control/status register (ADC_CSR)
- 24.11.4 ADC configuration register 1 (ADC_CR1)
- 24.11.5 ADC configuration register 2 (ADC_CR2)
- 24.11.6 ADC configuration register 3 (ADC_CR3)
- 24.11.7 ADC data register high (ADC_DRH)
- 24.11.8 ADC data register low (ADC_DRL)
- 24.11.9 ADC Schmitt trigger disable register high (ADC_TDRH)
- 24.11.10 ADC Schmitt trigger disable register low (ADC_TDRL)
- 24.11.11 ADC high threshold register high (ADC_HTRH)
- 24.11.12 ADC high threshold register low (ADC_HTRL)
- 24.11.13 ADC low threshold register high (ADC_LTRH)
- 24.11.14 ADC low threshold register low (ADC_LTRL)
- 24.11.15 ADC watchdog status register high (ADC_AWSRH)
- 24.11.16 ADC watchdog status register low (ADC_AWSRL)
- 24.11.17 ADC watchdog control register high (ADC_AWCRH)
- 24.11.18 ADC watchdog control register low (ADC_AWCRL)
- 24.12 ADC register map and reset values
- 25 Revision history