Professional Documents
Culture Documents
STM32L0 ULP Peripherals
STM32L0 ULP Peripherals
OBJECTIVES 2
Flash I/F
SW Debug 64KB Power Supply
CORTEXTM-M0+
M0+ Flash Memory Reg 1.8V/1.5V/1.2V
CPU POR/PDR/BOR/PVD
32 MHz 2KB
RTCSEL [1:0] =
Alarm A
HSE / 32
hh:mm:ss:ssr
Smooth dd/mm/year
LSE
Calibration
LSI Alarm A Event
hh:mm:ss:ssr
RTCCLK
dd/mm/year =
Calendar Calendar
ssr
(binary format)
Asynchronous Synchronous ck_spre OSEL
7-bit Prescaler 15-bit Prescaler Day/date/month/year HH:mm:ss
(12/24 format)
PREDIV_A [6:0] PREDIV_S [14:0]
Control
Output
1 Hz
RTC_CALIB
512 Hz Wake-Up
COSEL RTC_OUT
Prescaler
/2, /4, /8, /16 Wake-Up Event
16-bit autoreload
Timer
RTC Calendar 6
Calendar
12h/24h
Shadow
registers DR TR SSR
Wake-Up Timer (WUT) 7
Prescaler
/2, /4, /8, /16 Wake-Up Event
16-bit autoreload
Timer
1
2 1s 18.2 h 1s resolution
ck_spre = 1Hz
3 18.2 s 36.4 h 1s resolution
BACKUP domain 8
Wakeup Logic
Wakeup Pin 1 /
Tamper 2
• By default and after reset, the RTC registers are write protected to
avoid possible parasitic write accesses.
• DBP bit must be set in PWR_CR to enable RTC write access
* Except for the clear of Alarm and Wakeup timer interrupt flags
Digital peripherals
LPTIM
Low-Power Timer Block diagram 13
APB bus
Registers
Up/Down 1 2 3
Glitch
Encoder Filter Input 2
Glitch
1 2 3
Filter Input 1
up to 8 ext
trigger
Glitch
s/w
Filter trigger 16-bit ARR
MUX trigger
Glitch
Filter
2 consecutive 2 consecutive 2 consecutive
samples samples samples
CLK
INPUT
Filtered
OUTPUT
Filtered glitches
• 3 configurable waveforms
• PWM waveform
• One Pulse waveform
POL = 0
• Set Once waveform
LPTIMx_ARR
LPTIMx_CMP
LPTIMx_CNT
PWM
One Pulse
Set Once
LPTIM as Encoder Interface 16
1 2 3
• Encoder mode
• Same operation as Encoder mode on General Purpose Timers
• Only available when LPTIM runs in Continuous mode
CLK
INPUT1
INPUT2
COUNTER
LPTIM as External Pulse Counter 17
Sampling Glitch
1 2 3
Filter
Input 1
16-bit ARR
16-bit ARR
Digital peripherals
USART
USART – Block Diagram 19
Transmit Data
Register
Clocks
SCLK Control
SCLK PCLK
SYSCLK
USART peripheral HSI
LSE
USART Features List 20
T measured
T measured
Master Slave
SCLK SCK
RX MISO
USART SPI
TX MOSI
NSS
Full Duplex
USART – Single Wire Half Duplex mode 24
VDD
R = 10 KΩ
USART1 USART2
TX TX
Half Duplex
USART – Smart Card Mode 25
T = 0, T = 1 support
USART C1 C5
TX
C2 C6
C3 C7
SCLK
C4 C8
USART – IrDA SIR Encoder Decoder 26
USART
IrDA
SIR TX
Encoder
USART IrDA
transceiver
SIR RX
Decoder
USART – RS485, RS422 Transceiver Control 27
TX signal
TX +
USART
DE RS485
transceiver -
RX
The times are expressed in oversampling time units (1/8 or 1/16 of bit time)
Digital peripherals
Low-Power UART (LPUART)
LPUART 29
SYSCLK
HSI16 to LPUART
LSE
APB (PCLK)
256 × fCK
Tx/Rx Baud =
LPUARTDIV
Digital peripherals
2
IC
I2C Block Diagram 33
PCLK
SYSCFG_CFGR1 /
HSI16 Data control I2C_PBx_FM+
SYSCLK I2C_CLK WUPEN
Digital Analog
Noise Noise
SMBus PEC Filter Filter GPIO SDA
gen./check logic
RCC_CFGR_I2CxSEL Wake-Up on
address match Digital Analog
Clock control
Noise Noise
MASTER clk GPIO
control Filter Filter SCL
logic
SLAVE clk.
stretching
SMBus
Timeout chck
SYSCFG_CFGR1 /
I2C_PBx_FM+
PCLK
Registers
APB bus
Wakeup from STOP on address match 34
• When I2C_CLK clock is HSI, the I2C is able to wakeup MCU from
STOP when it receives its slave address. All addressing mode are
supported:
• During STOP mode and no address reception: HSI is switched off
2 configurable addresses
Easy Master mode management 35
• For payload <= 255 bytes : only 1 write action needed !! (apart data rd/wr)
I2Cx_CR2 is written with : START enable (START=1)
Slave address configuration (SADD)
Transfer direction (RD_WRN)
Number of bytes to be transferred (NBYTES = N)
Autoend enable (AUTOEND=1) => peripheral will
generate STOP automatically after N bytes are sent
AUTOEND
0 : Software end mode End of transfer SW control after NBYTES data transfer :
• TC flag is set. Interrupt if TCIE=1.
• TC is cleared when START or STOP is set by SW
If START=1 : RESTART condition is sent
1 : Automatic end mode STOP condition sent after NBYTES data transfer
Analog peripherals
Power Supply Supervisors
Power Supply monitoring
VDD / VDDA / Reset circuitry 37
2.0V
100mV hysteresis
(PVD) 1.9V
(1.9V min)
1.8V
(BOR)
1.8V (min) 100mV hysteresis
1.7V
PVD interrupt
PVD enabled (if enabled)
by Software
PVD output
BOR reset
(NRST) Option Bytes
Reload
BOR/PDR reset
(NRST)
POR/PDR
(NRST)
38
Analog peripherals
COMPx
COMPx Block diagram 39
COMP1 window
mode selection COMP1 polarity WAKEUP
selection EXTI_LINE_21
PA1 +
COMP1 GPIOx
COMP1_VALUE
-
PA0 TIM2_ETR
PA4 (DAC) TIM2_CH4
PA5 TIM21_ETR
VREFINT TIM21_CH2
TIM22_ETR
COMP2 non-inverting TIM22_CH1
input selection LPTIM_ETR
COMP1 inverting LPTIM_CH2
PA3 input selection COMP2 polarity WAKEUP
PB4 selection EXTI_LINE_22
+
PB5
COMP2 GPIOx
PB6
PB7 COMP2_VALUE
-
PA2 TIM2_ETR
PA4 (DAC) TIM2_CH4
PA5 TIM21_ETR
PB3 TIM21_CH2
VREFINT TIM22_ETR
¾ VREFINT TIM22_CH1
½ VREFINT
LPTIM_ETR
¼ VREFINT
LPTIM_CH2
COMP2 inverting
input selection
COMP features 40
• Parameters at a glance
• Full voltage range 2V < Vdda < 3.6V
• Propagation time vs consumption (typ. 2.7 < Vdd < 3.6V, for 200 mV step with 100
mV overdrive)
• High speed mode: 120ns / 100µA
• Low power mode: 1µs / 3µA
Analog peripherals
ADC
1.8V ~ 3.6V
ADC Block Diagram 42
Vref+
VDDA
VSSA
AUTOFF
ADC_IN0
ADEN/ADDIS
.
.
.
. ANALOG MUX Bias & Ref
. GPIO
. Ports
. VIN
.
CONVERTED DATA Oversampler
ADDRESS/DATA BUS
.
ADC_IN15
S&H Sampling
Temp Sensor
time control SAR ADC
VREFINT
16-bit DATA
VLCD Analog Watchdog
Start
Higher Threshold
Input Sel. &
Scan Control
Lower Threshold
AUTDLY
Start & Stop
ADSTP Control s/w trigger h/w trigger
… DMA
Trigger enable and request
TRG7 edge selection
EXTSEL[2:0] bits
Interrupt
request
Clock sources (ADC) 43
ADC PERIPHERAL
PCLK ADC Prescalers: Digital Interface
/1 or /2 or /4
Analog Interface
16MHz
max
16MHz internal /1, /2, /4 .. /256
oscillator
Lower resolution allows faster conversion times for applications where high
data precision is not required.
Auto delayed conversion 45
HW/SW Trigger
EOC Flag
i Channel conversion #i
Note : A trigger event (for the same group of conversions) occurring during this delay is ignored.
HW/SW Trigger
AUTOFF =1
AUTDLY =0
1 2 1
OFF ON OFF ON OFF
AUTOFF =0 1 2 1
AUTDLY =0 ON
• Principle
• The ADC hardware can do averaging according to the formula:
• Benefits
• Data rate reduction
• SNR improvement
• Basic filtering
STM32L0 implementation
48
• ADC does oversampling and averaging by HW
• N is setup by OVFS[2:0], 2x to 256x
• M by OVSS[3:0], 0 to 8 bit
19 0
Raw 20-bit
accumulator 0xDEDA1
Programmable Up to 8 bits
shift
15 0
16-bit result, the 0xDEDA
MSB is truncated Shift by 4 bits in this example
Analog peripherals
Glass LCD Controller (LCD)
LCD Controller Block diagram 50
Frequency generator
LCDCLK
16-bit prescaler
COM0
COM3
Divide by 16 to 31
ADDRESS/DATA BUS
Interrupt SEG0
ck_div
COM
8-to-1 MUX
LCD RAM SEG Driver Analog
switch
(32x16 bits) Driver array
SEG27
Controller
The frame frequency must be selected to be within a range of around ~30 Hz to ~100 Hz
Memory/Segment mapping 52
Digit 16 Segment 31 …… 2 1 0
X 3
A COM0
Example of Writing the
I character “A” on the
F H J B Liquid crystal display COM1
first digit
G K
COM2
E L M N C
COM3
DP
D
SEG1 I J K N
SEG2 A B C DP COM7
SEG3 H G L M
0x 4 D 7 0 LCD RAM
Common/Segment driver(1/2) 53
• The common has the maximum amplitude VLCD or VSS only in the
corresponding phase of a frame cycle.
• During the other phases, the signal amplitude is 1/4 VLCD or 3/4 VLCD in
case of 1/4 bias or 1/3 VLCD or 2/3 VLCD in case of 1/3 Bias and 1/2 VLCD
in case of 1/2 Bias.
• The first frame generated is the odd one followed by an even one
• Five Duty ratios can be selected: Static Duty, 1/2 Duty, 1/3 Duty, 1/4 Duty or
1/8 Duty
COM0
2/3 VLCD
each of them controls four segments 1/3 VLCD
VSS
A segment is active if the corresponding VLCD
COM1
segment line gets a maximum voltage opposite 2/3 VLCD
1/3 VLCD
to the common
VSS
VLCD
Common signals are phase inverted in order
COM2
2/3 VLCD
VSS
COM3
2/3 VLCD
SEGn needs to be inactive (VSS) during phase 0 1/3 VLCD
of an odd frame and active (VLCD) during phase VSS
SEGn
2/3 VLCD
1/3 VLCD
To deactivate segments[n+44] connected to VSS
COM1, SEGn needs to be active during the Pixels[n] Pixels[n+44] Pixels[n+88] Pixels[n+132]Pixels[n] Pixels[n+44]Pixels[n+88] Pixels[n+132]
phase 1 of an odd frame and inactive during the RAM refresh RAM refresh
phase 1 of an even frame when COM1 is active
LCD RAM LCD RAM
VLCD
COM0
2/3 VLCD
1/3 VLCD
VSS
www.st.com/stm32l0