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.

More Related Content

What's hot

SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
Anurag Tomar
 
Arm architecture
Arm architectureArm architecture
UART
UARTUART
Pci express technology 3.0
Pci express technology 3.0Pci express technology 3.0
Pci express technology 3.0
Biddika Manjusree
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)Varun Mahajan
 
PCI Express Verification using Reference Modeling
PCI Express Verification using Reference ModelingPCI Express Verification using Reference Modeling
PCI Express Verification using Reference ModelingDVClub
 
Introduction to arm processor
Introduction to arm processorIntroduction to arm processor
Introduction to arm processor
RAMPRAKASHT1
 
ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
Dwight Sabio
 
I2C-Bus Design and Verification Specs
I2C-Bus Design and Verification SpecsI2C-Bus Design and Verification Specs
I2C-Bus Design and Verification Specs
Mostafa Khamis
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Sudhanshu Janwadkar
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
RISC-V International
 
Bootloaders
BootloadersBootloaders
Bootloaders
Anil Kumar Pugalia
 
axi protocol
axi protocolaxi protocol
axi protocol
Azad Mishra
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
Gaurav Verma
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration
AKHIL MADANKAR
 
SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)
SUNODH GARLAPATI
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
Ankur Soni
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller
pavihari
 

What's hot (20)

SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
UART
UARTUART
UART
 
Pci express technology 3.0
Pci express technology 3.0Pci express technology 3.0
Pci express technology 3.0
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
PCI Express Verification using Reference Modeling
PCI Express Verification using Reference ModelingPCI Express Verification using Reference Modeling
PCI Express Verification using Reference Modeling
 
Introduction to stm32-part2
Introduction to stm32-part2Introduction to stm32-part2
Introduction to stm32-part2
 
Introduction to arm processor
Introduction to arm processorIntroduction to arm processor
Introduction to arm processor
 
ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
 
Introduction to stm32-part1
Introduction to stm32-part1Introduction to stm32-part1
Introduction to stm32-part1
 
I2C-Bus Design and Verification Specs
I2C-Bus Design and Verification SpecsI2C-Bus Design and Verification Specs
I2C-Bus Design and Verification Specs
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
 
Bootloaders
BootloadersBootloaders
Bootloaders
 
axi protocol
axi protocolaxi protocol
axi protocol
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration
 
SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)SPI introduction(Serial Peripheral Interface)
SPI introduction(Serial Peripheral Interface)
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller
 

Similar to STM32 Microcontroller Clocks and RCC block

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 EditadoTexas Instruments
 

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
 
Pll in lpc2148
Pll in lpc2148Pll in lpc2148
Pll in lpc2148
 
HCS08 Overview
HCS08 OverviewHCS08 Overview
HCS08 Overview
 
ESD III UNIT.pptx
ESD III UNIT.pptxESD III UNIT.pptx
ESD III UNIT.pptx
 
Lecture on PIC-1.pptx
Lecture on PIC-1.pptxLecture on PIC-1.pptx
Lecture on PIC-1.pptx
 
Microchip NANOWatt Technology
Microchip NANOWatt TechnologyMicrochip NANOWatt Technology
Microchip NANOWatt Technology
 
embedded system introduction to microcontrollers
embedded system introduction to microcontrollersembedded system introduction to microcontrollers
embedded system introduction to microcontrollers
 
Overview of LPC213x MCUs
Overview of LPC213x MCUsOverview of LPC213x MCUs
Overview of LPC213x MCUs
 
SIMH multi-system simulator
SIMH multi-system simulatorSIMH multi-system simulator
SIMH multi-system simulator
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03
 
pic_1.pdf
pic_1.pdfpic_1.pdf
pic_1.pdf
 
Manual cpu clocking system
Manual cpu clocking systemManual cpu clocking system
Manual cpu clocking system
 
Overview of LPC214x MCUs
Overview of LPC214x MCUsOverview of LPC214x MCUs
Overview of LPC214x MCUs
 
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
 
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
 
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...
 
Xmega d4 microcontroller
Xmega d4 microcontrollerXmega d4 microcontroller
Xmega d4 microcontroller
 
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
 
2502s
2502s2502s
2502s
 
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
 

Recently uploaded

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 

Recently uploaded (20)

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 

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

  1. 1
  2. 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.
  3. 1 x 100 /2
  4. f(vco input clock)
  5. 1 x 100 /2
  6. 50MHz
  7. 50MHz
  8. 50MHz 0.02 micro seconds ---- > 1tick 1ms --> ? 1 ms / 0.02 micro 50MHz/ 1000
  9. C