SlideShare a Scribd company logo
Clocks
Understanding HSI,HSE,PLL,HCLK,PCLKx
and configuration
For full video course on Microcontroller and RTOS
programming please visit : www.fastbitlab.com
All courses are hosted on
Udemy.com
Click here to enroll FREE !!!!
http://bit.ly/2P47IeX
Click here to watch free preview and enroll
http://bit.ly/2QaW0M9
Click here to watch free preview and enroll
http://bit.ly/2SA2uFO
Click here to watch free preview and enroll
http://bit.ly/2PAQRQh
Click here to watch free preview and enroll
http://bit.ly/2AEcneA
Click here to watch free preview and enroll
http://bit.ly/2zhqDrX
Click here to watch free preview and enroll
http://bit.ly/2OjgFf7
System Clock(SYSCLK)
• Three different clock sources can be used to drive the system clock
(SYSCLK):
– HSI oscillator clock
– HSE oscillator clock
– Two main PLL (PLL) clocks
• The devices have the two following secondary clock sources
– 32 kHz low-speed internal RC (LSI RC) which drives the independent
watchdog and, optionally, the RTC used for Auto-wakeup from the
Stop/Standby mode.
– 32.768 kHz low-speed external crystal (LSE crystal) which optionally
drives the RTCclock (RTCCLK)
NUCLEO-F446RE board
• HSI  16MHz (Internal to MCU)
• HSE 8MHz (External to MCU)
• PLL can generate clock up to 180MHz (Internal
to MCU)
• LSI32kHz (Internal to MCU)
• LSE32.768kHz (External to MCU)
Default Clock State
After reset of the MCU,
HSI is ON, HSE is OFF , PLL is OFF, LSE is OFF,
LSI is OFF
So, SYSCLK is sourced by HSI .
I.e : SYSCLK = 16MHz
Each clock source can be switched on or off independently when it is not used, to
optimize power consumption.
The HSI is used (enabled by hardware) as system clock source after startup from
Reset, wake-up from STOP and STANDBY mode, or in case of failure of the HSE used
directly or indirectly as system clock
The HSI RC oscillator has the advantage of providing a clock source at low cost (no
external components).
It also has a faster startup time than the HSE crystal oscillator.
However, even with calibration the frequency is less accurate than an external crystal
oscillator or ceramic resonator
The HSI signal can also be used as a backup source (auxiliary clock) if the HSE crystal
oscillator fails.
HSI
STM32 Cube Clock Handling APIs
STM32 HAL RCC Driver
stm32f4xx_hal_rcc.c
stm32f4xx_hal_rcc_ex.c
stm32f4xx_hal_rcc.h
stm32f4xx_hal_rcc_ex.h
Source header
ex = Extension
Methods to configure the STSCLK
Source
• First Enable the required clock and wait until the clock is
ready . If your application needs PLL, then configure the PLL
and enable it.
• Initializes the CPU, AHB and APB busses clock prescalers
according to your application requirements . Do not cross
maximum limits.
• Configure the flash latency properly by referring to MCU RM
• Select newly enabled Clock as SYSCLK
STM32 Cube Clock Handling APIs
1) HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct)
2) HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct,
uint32_t FLatency)
RCC_OscInitTypeDef
RCC Internal/External
Oscillator (HSE, HSI, LSE and
LSI) configuration structure
definition
RCC_ClkInitTypeDef
RCC System, AHB and APB
busses clock configuration
structure definition
HSI Calibration
The operating temperature has an impact on the accuracy of
the RC oscillators. At 25 °C, the HIS oscillators have an accuracy
of ±1% typically, but in the temperature range of -40 to 105 °C,
the accuracy decreases.
To compensate for the influence of temperature in the application,
the output frequency of the HSI oscillator can be further trimmed
by the user runtime calibration routine to improve the HSI
frequency accuracy. This may prove crucial for communication
peripherals.
HSI Calibration adjustment
HSI RC oscillators are factory
calibrated by ST to have a 1%
accuracy at TA = 25 °C. After
reset, the factory calibration
value is automatically loaded in
the internal calibration bits.
HSI Calibration adjustment
The frequency of the internal RC oscillators
can be fine-tuned to achieve better accuracy
with wider temperature and supply voltage
ranges. The trimming bits are used for this
purpose.
the calibration value is loaded in
HSICAL[7:0] bits after reset. Five
trimming bits HSITRIM[4:0] are
used for fine-tuning. The default
trimming value is 16
HSI Calibration adjustment
• Effect of HSITRIM[4:0]
– The default trimming value is 16
– An increase in this trimming value causes an increase
in HSI frequency
– Decrease in this trimming value causes an decrease in
HSI frequency
– The HSI oscillator is fine-tuned in steps of 0.5%
(around 80 kHz)
HSI Calibration adjustment
• Summary
– Writing a trimming value in the range of 17 to 31
increases the HSI frequency.
– Writing a trimming value in the range of 0 to 15
decreases the HSI frequency
– Writing a trimming value equal to 16 causes the
HSI frequency to keep its default value. (+- 1%)
HSE BYPASS
HSE BYPASS-NUCLEO-F446RE
Main MCUST link MCU
STLINK CKT
OSC_IN
MCO
PA8
8MHz
Exercise
Using HSE Configure the SYSCLK as 8MHz.
AHB clock as 4MHz (HCLK)
APB1 clock as 2MHz (PCLK1)
APB2 clock as 2MHz (PCLK2)
PLL(Phase Locked Loop)
• The PLL engine of the MCU is used to generate
different high frequency output clocks by
taking input clock sources such as HSE or HSI.
• By using PLL you can drive SYSCLK up to
180MHz in STM32F446RE MCU
Main PLL
VCO /P
/Q
/R
/M
X N
PLL Source Mux
PLLCLK
HSE
HSI 16MHz
8MHz
f(vco input clock) f(vco output clock)
Main PLL
VCO/M
PLL Source Mux
HSE
HSI 16MHz
8MHz
Division factor for the main PLL (PLL) input clock
1MHz < f(vco input clock) <= 2MHz
f(vco input clock) f(vco output clock)
Main PLL
VCO/M
PLL Source Mux
HSE
HSI 16MHz
8MHz
Main PLL (PLL) multiplication factor for VCO
1MHz < f(vco input clock) <= 2MHz
f(vco input clock) f(vco output clock)
X N
100MHz<=f(vco output clock) <= 432MHz
PLL Formulas
PLLCLKPLLCLK
Exercise
• Write an application to generate below HCLK
Frequencies using PLL . Use HSI as PLL’s input
source and repeat the exercise using HSE as
input source.
– 50MHz
– 84MHz
– 120MHz
PLL configuration
VCO /P
/Q
/R
/M
X N
PLL Source Mux
PLLCLK
HSE
HSI 16MHz
8MHz
f(vco input clock) f(vco output clock)
PLL configuration
SYSCLK HCLK
AHB
Prescaler
PLLCLK
50MHz
PLL configuration
SYSCLK HCLK
AHB
Prescaler
PLLCLK
84MHz
PLL configuration
SYSCLK HCLK
AHB
Prescaler
PLLCLK
120MHz
Exercise
• Write an application which does PLL
configuration to boost the HCLK to maximum
capacity (for STM32F446RE it is:180MHz). Use
HSE as PLL Source.
Ad

More Related Content

What's hot (20)

ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
EdutechLearners
 
Stm32 f4 first touch
Stm32 f4 first touchStm32 f4 first touch
Stm32 f4 first touch
Benux Wei
 
Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 Introduction
Dr. Pankaj Zope
 
Linux I2C
Linux I2CLinux I2C
Linux I2C
KaidenYu
 
ARM Micro-controller
ARM Micro-controllerARM Micro-controller
ARM Micro-controller
Ravikumar Tiwari
 
L10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 pL10 assembly-language-programming-of-atmega328 p
L10 assembly-language-programming-of-atmega328 p
rsamurti
 
ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
Kshitij Gorde
 
Arm Processors Architectures
Arm Processors ArchitecturesArm Processors Architectures
Arm Processors Architectures
Mohammed Hilal
 
Arm architecture
Arm architectureArm architecture
Arm architecture
Pantech ProLabs India Pvt Ltd
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
Mohammed Gomaa
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
Gaurav Verma
 
Spyglass dft
Spyglass dftSpyglass dft
Spyglass dft
kumar gavanurmath
 
CPU Verification
CPU VerificationCPU Verification
CPU Verification
Ramdas Mozhikunnath
 
AMBA 5 COHERENT HUB INTERFACE.pptx
AMBA 5 COHERENT HUB INTERFACE.pptxAMBA 5 COHERENT HUB INTERFACE.pptx
AMBA 5 COHERENT HUB INTERFACE.pptx
Sairam Chebrolu
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
Emertxe Information Technologies Pvt Ltd
 
Advanced Pipelining in ARM Processors.pptx
Advanced Pipelining  in ARM Processors.pptxAdvanced Pipelining  in ARM Processors.pptx
Advanced Pipelining in ARM Processors.pptx
JoyChowdhury30
 
The I2C Interface
The I2C InterfaceThe I2C Interface
The I2C Interface
Corrado Santoro
 
ARM Processor
ARM ProcessorARM Processor
ARM Processor
Aniket Thakur
 
Introduction to FreeRTOS
Introduction to FreeRTOSIntroduction to FreeRTOS
Introduction to FreeRTOS
ICS
 
Double data rate (ddr)
Double data rate (ddr)Double data rate (ddr)
Double data rate (ddr)
Anderson Huang
 

Similar to STM32 Microcontroller Clocks and RCC block (20)

Stm32f303 rest and Clock contol
Stm32f303 rest and Clock contolStm32f303 rest and Clock contol
Stm32f303 rest and Clock contol
Prem Sanil
 
Pll in lpc2148
Pll in lpc2148Pll in lpc2148
Pll in lpc2148
Aarav Soni
 
HCS08 Overview
HCS08 OverviewHCS08 Overview
HCS08 Overview
Premier Farnell
 
ESD III UNIT.pptx
ESD III UNIT.pptxESD III UNIT.pptx
ESD III UNIT.pptx
ECEHOD19
 
Lecture on PIC-1.pptx
Lecture on PIC-1.pptxLecture on PIC-1.pptx
Lecture on PIC-1.pptx
godfrey35
 
Microchip NANOWatt Technology
Microchip NANOWatt TechnologyMicrochip NANOWatt Technology
Microchip NANOWatt Technology
Emanuele Bonanni
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollers
BarER4
 
Overview of LPC213x MCUs
Overview of LPC213x MCUsOverview of LPC213x MCUs
Overview of LPC213x MCUs
Premier Farnell
 
SIMH multi-system simulator
SIMH multi-system simulatorSIMH multi-system simulator
SIMH multi-system simulator
Francesca Capochiani
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03
Premier Farnell
 
pic_1.pdf
pic_1.pdfpic_1.pdf
pic_1.pdf
ZatinGupta2
 
Manual cpu clocking system
Manual cpu clocking systemManual cpu clocking system
Manual cpu clocking system
reanto vilchez
 
Overview of LPC214x MCUs
Overview of LPC214x MCUsOverview of LPC214x MCUs
Overview of LPC214x MCUs
Premier Farnell
 
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summaryAtmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Rajan Gautam
 
Q46S-66-Auto-Chem-Sulfite-Monitor.pdf
Q46S-66-Auto-Chem-Sulfite-Monitor.pdfQ46S-66-Auto-Chem-Sulfite-Monitor.pdf
Q46S-66-Auto-Chem-Sulfite-Monitor.pdf
ENVIMART
 
MIXED SIGNAL VLSI TECHNOLOGY BASED SoC DESIGN FOR TEMPERATURE COMPENSATED pH...
MIXED SIGNAL VLSI TECHNOLOGY BASED SoC DESIGN FOR TEMPERATURE COMPENSATED  pH...MIXED SIGNAL VLSI TECHNOLOGY BASED SoC DESIGN FOR TEMPERATURE COMPENSATED  pH...
MIXED SIGNAL VLSI TECHNOLOGY BASED SoC DESIGN FOR TEMPERATURE COMPENSATED pH...
Abhijeet Powar
 
Xmega d4 microcontroller
Xmega d4 microcontrollerXmega d4 microcontroller
Xmega d4 microcontroller
Alfredo Santillan
 
Q46F-82-Auto-Chem-Fluoride-Monitor.pdf
Q46F-82-Auto-Chem-Fluoride-Monitor.pdfQ46F-82-Auto-Chem-Fluoride-Monitor.pdf
Q46F-82-Auto-Chem-Fluoride-Monitor.pdf
ENVIMART
 
2502s
2502s2502s
2502s
Andi Gian
 
03 Mcu Day 2009 (C2000) 8 13 Editado
03   Mcu Day 2009 (C2000) 8 13   Editado03   Mcu Day 2009 (C2000) 8 13   Editado
03 Mcu Day 2009 (C2000) 8 13 Editado
Texas Instruments
 
Stm32f303 rest and Clock contol
Stm32f303 rest and Clock contolStm32f303 rest and Clock contol
Stm32f303 rest and Clock contol
Prem Sanil
 
Pll in lpc2148
Pll in lpc2148Pll in lpc2148
Pll in lpc2148
Aarav Soni
 
ESD III UNIT.pptx
ESD III UNIT.pptxESD III UNIT.pptx
ESD III UNIT.pptx
ECEHOD19
 
Lecture on PIC-1.pptx
Lecture on PIC-1.pptxLecture on PIC-1.pptx
Lecture on PIC-1.pptx
godfrey35
 
Microchip NANOWatt Technology
Microchip NANOWatt TechnologyMicrochip NANOWatt Technology
Microchip NANOWatt Technology
Emanuele Bonanni
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollers
BarER4
 
Overview of LPC213x MCUs
Overview of LPC213x MCUsOverview of LPC213x MCUs
Overview of LPC213x MCUs
Premier Farnell
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03
Premier Farnell
 
Manual cpu clocking system
Manual cpu clocking systemManual cpu clocking system
Manual cpu clocking system
reanto vilchez
 
Overview of LPC214x MCUs
Overview of LPC214x MCUsOverview of LPC214x MCUs
Overview of LPC214x MCUs
Premier Farnell
 
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summaryAtmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Rajan Gautam
 
Q46S-66-Auto-Chem-Sulfite-Monitor.pdf
Q46S-66-Auto-Chem-Sulfite-Monitor.pdfQ46S-66-Auto-Chem-Sulfite-Monitor.pdf
Q46S-66-Auto-Chem-Sulfite-Monitor.pdf
ENVIMART
 
MIXED SIGNAL VLSI TECHNOLOGY BASED SoC DESIGN FOR TEMPERATURE COMPENSATED pH...
MIXED SIGNAL VLSI TECHNOLOGY BASED SoC DESIGN FOR TEMPERATURE COMPENSATED  pH...MIXED SIGNAL VLSI TECHNOLOGY BASED SoC DESIGN FOR TEMPERATURE COMPENSATED  pH...
MIXED SIGNAL VLSI TECHNOLOGY BASED SoC DESIGN FOR TEMPERATURE COMPENSATED pH...
Abhijeet Powar
 
Q46F-82-Auto-Chem-Fluoride-Monitor.pdf
Q46F-82-Auto-Chem-Fluoride-Monitor.pdfQ46F-82-Auto-Chem-Fluoride-Monitor.pdf
Q46F-82-Auto-Chem-Fluoride-Monitor.pdf
ENVIMART
 
03 Mcu Day 2009 (C2000) 8 13 Editado
03   Mcu Day 2009 (C2000) 8 13   Editado03   Mcu Day 2009 (C2000) 8 13   Editado
03 Mcu Day 2009 (C2000) 8 13 Editado
Texas Instruments
 
Ad

Recently uploaded (20)

AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
Could Virtual Threads cast away the usage of Kotlin Coroutines - DevoxxUK2025
João Esperancinha
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
AI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of DocumentsAI Agents at Work: UiPath, Maestro & the Future of Documents
AI Agents at Work: UiPath, Maestro & the Future of Documents
UiPathCommunity
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Ad

STM32 Microcontroller Clocks and RCC block

  • 2. For full video course on Microcontroller and RTOS programming please visit : www.fastbitlab.com All courses are hosted on Udemy.com
  • 3. Click here to enroll FREE !!!! http://bit.ly/2P47IeX
  • 4. Click here to watch free preview and enroll http://bit.ly/2QaW0M9
  • 5. Click here to watch free preview and enroll http://bit.ly/2SA2uFO
  • 6. Click here to watch free preview and enroll http://bit.ly/2PAQRQh
  • 7. Click here to watch free preview and enroll http://bit.ly/2AEcneA
  • 8. Click here to watch free preview and enroll http://bit.ly/2zhqDrX
  • 9. Click here to watch free preview and enroll http://bit.ly/2OjgFf7
  • 10. System Clock(SYSCLK) • Three different clock sources can be used to drive the system clock (SYSCLK): – HSI oscillator clock – HSE oscillator clock – Two main PLL (PLL) clocks • The devices have the two following secondary clock sources – 32 kHz low-speed internal RC (LSI RC) which drives the independent watchdog and, optionally, the RTC used for Auto-wakeup from the Stop/Standby mode. – 32.768 kHz low-speed external crystal (LSE crystal) which optionally drives the RTCclock (RTCCLK)
  • 11. NUCLEO-F446RE board • HSI  16MHz (Internal to MCU) • HSE 8MHz (External to MCU) • PLL can generate clock up to 180MHz (Internal to MCU) • LSI32kHz (Internal to MCU) • LSE32.768kHz (External to MCU)
  • 12. Default Clock State After reset of the MCU, HSI is ON, HSE is OFF , PLL is OFF, LSE is OFF, LSI is OFF So, SYSCLK is sourced by HSI . I.e : SYSCLK = 16MHz Each clock source can be switched on or off independently when it is not used, to optimize power consumption.
  • 13. The HSI is used (enabled by hardware) as system clock source after startup from Reset, wake-up from STOP and STANDBY mode, or in case of failure of the HSE used directly or indirectly as system clock The HSI RC oscillator has the advantage of providing a clock source at low cost (no external components). It also has a faster startup time than the HSE crystal oscillator. However, even with calibration the frequency is less accurate than an external crystal oscillator or ceramic resonator The HSI signal can also be used as a backup source (auxiliary clock) if the HSE crystal oscillator fails. HSI
  • 14. STM32 Cube Clock Handling APIs STM32 HAL RCC Driver stm32f4xx_hal_rcc.c stm32f4xx_hal_rcc_ex.c stm32f4xx_hal_rcc.h stm32f4xx_hal_rcc_ex.h Source header ex = Extension
  • 15. Methods to configure the STSCLK Source • First Enable the required clock and wait until the clock is ready . If your application needs PLL, then configure the PLL and enable it. • Initializes the CPU, AHB and APB busses clock prescalers according to your application requirements . Do not cross maximum limits. • Configure the flash latency properly by referring to MCU RM • Select newly enabled Clock as SYSCLK
  • 16. STM32 Cube Clock Handling APIs 1) HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct) 2) HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency)
  • 17. RCC_OscInitTypeDef RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
  • 18. RCC_ClkInitTypeDef RCC System, AHB and APB busses clock configuration structure definition
  • 19. HSI Calibration The operating temperature has an impact on the accuracy of the RC oscillators. At 25 °C, the HIS oscillators have an accuracy of ±1% typically, but in the temperature range of -40 to 105 °C, the accuracy decreases. To compensate for the influence of temperature in the application, the output frequency of the HSI oscillator can be further trimmed by the user runtime calibration routine to improve the HSI frequency accuracy. This may prove crucial for communication peripherals.
  • 20. HSI Calibration adjustment HSI RC oscillators are factory calibrated by ST to have a 1% accuracy at TA = 25 °C. After reset, the factory calibration value is automatically loaded in the internal calibration bits.
  • 21. HSI Calibration adjustment The frequency of the internal RC oscillators can be fine-tuned to achieve better accuracy with wider temperature and supply voltage ranges. The trimming bits are used for this purpose. the calibration value is loaded in HSICAL[7:0] bits after reset. Five trimming bits HSITRIM[4:0] are used for fine-tuning. The default trimming value is 16
  • 22. HSI Calibration adjustment • Effect of HSITRIM[4:0] – The default trimming value is 16 – An increase in this trimming value causes an increase in HSI frequency – Decrease in this trimming value causes an decrease in HSI frequency – The HSI oscillator is fine-tuned in steps of 0.5% (around 80 kHz)
  • 23. HSI Calibration adjustment • Summary – Writing a trimming value in the range of 17 to 31 increases the HSI frequency. – Writing a trimming value in the range of 0 to 15 decreases the HSI frequency – Writing a trimming value equal to 16 causes the HSI frequency to keep its default value. (+- 1%)
  • 25. HSE BYPASS-NUCLEO-F446RE Main MCUST link MCU STLINK CKT OSC_IN MCO PA8 8MHz
  • 26. Exercise Using HSE Configure the SYSCLK as 8MHz. AHB clock as 4MHz (HCLK) APB1 clock as 2MHz (PCLK1) APB2 clock as 2MHz (PCLK2)
  • 27. PLL(Phase Locked Loop) • The PLL engine of the MCU is used to generate different high frequency output clocks by taking input clock sources such as HSE or HSI. • By using PLL you can drive SYSCLK up to 180MHz in STM32F446RE MCU
  • 28. Main PLL VCO /P /Q /R /M X N PLL Source Mux PLLCLK HSE HSI 16MHz 8MHz f(vco input clock) f(vco output clock)
  • 29. Main PLL VCO/M PLL Source Mux HSE HSI 16MHz 8MHz Division factor for the main PLL (PLL) input clock 1MHz < f(vco input clock) <= 2MHz f(vco input clock) f(vco output clock)
  • 30. Main PLL VCO/M PLL Source Mux HSE HSI 16MHz 8MHz Main PLL (PLL) multiplication factor for VCO 1MHz < f(vco input clock) <= 2MHz f(vco input clock) f(vco output clock) X N 100MHz<=f(vco output clock) <= 432MHz
  • 32. Exercise • Write an application to generate below HCLK Frequencies using PLL . Use HSI as PLL’s input source and repeat the exercise using HSE as input source. – 50MHz – 84MHz – 120MHz
  • 33. PLL configuration VCO /P /Q /R /M X N PLL Source Mux PLLCLK HSE HSI 16MHz 8MHz f(vco input clock) f(vco output clock)
  • 37. Exercise • Write an application which does PLL configuration to boost the HCLK to maximum capacity (for STM32F446RE it is:180MHz). Use HSE as PLL Source.

Editor's Notes

  • #17: 1
  • #21: The frequency of the internal RC oscillators can be fine-tuned to achieve better accuracy with wider temperature and supply voltage ranges. The trimming bits are used for this purpose.
  • #29: 1 x 100 /2
  • #30: f(vco input clock)
  • #34: 1 x 100 /2
  • #35: 50MHz
  • #36: 50MHz
  • #37: 50MHz 0.02 micro seconds ---- > 1tick 1ms --> ? 1 ms / 0.02 micro 50MHz/ 1000
  • #38: C
  翻译: