STM32 Tutorial : Clock, AHB & APB Buses configuration (Part1: Introduction)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everybody to this new tutorial today in this tutorial we will try together to set up the clock for our stm32 microcontroller we'll try to set up the system core clock and be busses so in this tutorial I will use the stm32f4discovery board which contains stm32f4 o 7v gt6 microcontroller so if you have another board or an automatic controller don't panic just follow these steps and instruction in this tutorial and download your appropriate file in document for your microcontroller so this tutorial is divided in 3 part the first part which is this one we'll try to make an introduction for the stm32 clocks and the second part we will try to write our code in order to set up the clocks in the final part third one we will try to display a real-time the value of the frequency using the STM studio real-time the bugger so stay tuned welcome to this first part of this tutorial which I will make an introduction now for the stm32 microcontroller clock so as you know any digital processor or microcontroller and need a continuous series of posts for him to work these pulses are called the clock in our derivative from the oscillator so as you know the microprocessor of your desktop or your laptop is running at a certain frequency so if you're going to buy a new microprocessor you will choose the microprocessor who have the higher frequency and of course a better architecture if you have of course the the money for that the GT ROM need a clock to work the GPU the microprocessor of your graphic card need a clock the microprocessor of your phone near the clock also so everything every digital processor or microcontroller need a clock for him to work so the clock help all the part of the microcontroller to work together so this the waveform of the clock is generally square signal with arising in the falling edge and the waveform can be also any different waveform like sawtooth etc so the most common one is still the S square signal so let's go here to this example here and as you can see here we have on the left our C code here in the right our assembly code here so as you know during the compiling and when the window of your project your compiler will translate your C code to in assembly code here so the assembly code is entered send double by your multiply and tore so as you can see here this instruction here move of BL subtract etc etc so every instruction can take one or more cycle all depend on the section itself so let's go here to the arm website here and inside the cortex and for technical reference manual here and here we have a table the cortex m4 etc set summary here we have all the assembly instruction for example the move as you can see here take one cycle the addition take one cycle the subtracted one cycle the multiply take one cycle they multiply accumulate here take two cycle so one cycle is equal to one divided by your clock system contract frequency for example we are using the stm32f4discovery board which contain STM 407 v g6 microcontroller this microcontroller is a his maximum frequency is 160 eight megahertz which mean 168 million process per second so one cycle is equal 1 divided by 168 million is equal to 5 point 95 so the move instruction take 5 point normally 5 point point 95 nanosecond for example the new generation of cortex m7 the stm32 F 6 for example is running at 200 megahertz so every so one cycle is take 5 nano second so the faster is the clock of the more session you can execute in one second so the stm32 microcontroller have to clock switches in internal clock sources and an external clock source so the the external clock sources we use a crystal clock as you can see in the screen the crystal clock for the STM f/4 discovery board which is running at 8 megahertz so according to the data sheet for the macron solar the external crystal clock should be between four to twenty six megahertz and the second source is the internal 16 megahertz or C oscillator so you may ask yourself right now a to question the first question may ask why would you use an external clock if the STM microcontroller have its own internal sixteen or six later so the answer is that the internal clock is less accurate than the external crystal clock so according to the datasheet the 16 and 16 megahertz internal clock is one percent accuracy which mean 4 or 16 megahertz or C clock which equal to 16 million persons per second we have 100 160 thousand processors more or less in every second this is equal to an error of 14.4 minutes per day so comparing this to an external clock which frequency stability is generally between 100 to between 10 to 100 ppm ppm is part per million and is like percent but per million instant so let's start with the crystal clock external clock with the frequent stability equal to one hand ppm and we suppose we have the external crystal clock have the same frequency at the internal which is 16 megahertz so the error every second is equal to 1 1600 pulses every second this equal to an error of eight point 64 second per day and for a crystal clock which Maxim with frequent stability as about 10 ppm the error will be 160 pulses more or less than every second and an error and we have an error about 0.86 second per day so we suppose there is no variation at the temperature and the capacitor load are correct for the external crystal clock so as you can see the crystal is about 100 to 1000 times accurate then the internal or C oscillator so let's go here to the digi-key let's take a look at the digit key digit key is one of the biggest electronic component supplier so let's take a look here looking for the crystal crystal you and we check we go to this crystal and live let's take a look here as you can see here the frequency stability is 100 ppm 10 ppm 11 ppm 120 etc but the majority are between 10 to 100 ppm for example as you can see here the frequent ability here the SMD surface-mount component crystal as you can see there's a through-hole component also as you can see here the frequency stability is 1550 ppm as you can see here now there's a more accurate accurate oscillator called TC x for temperature pulsate external oscillator the average is between 1 ppm this is more accurate than the normal crystal as you can see here the afraid most ability is about three zero point four e ppm 1 point 5 etc 0.5 so for example this one is the first one the frequency VT is about 2 ppm so for example the the Raspberry Pi use this t CX o mighty point 2 megahertz so this t CX all ninety point two megahertz so the frequent ability is about 2.5 ppm the raspberry pi is a well-known embedded tiny computer which include an ARM processor so let's take a look and there's also a more accurate one a crystal called Oh C exfol open controller extol crystal oscillator so this one is the frequent ability is a more more accurate than the previous one is about zero as you can see here 0.1 PPP and we talked here with PBB PBB is part per billion is more accurate so so in conclusion of this question so if you will use a critical peripheral like Ethernet USB we should buy an accurate frequency you have to use the external clock otherwise if the time is not supported in your application you can just use in the internal or C clock so the single question you may ask is how can we reach the maximum frequency which is equal to 168 168 megahertz for our microcontroller which is the stm32f4 or 7vg t6 microcontroller how can we use this maximum frequency which which the maximum frequency for the external clock is 26 megahertz and the internal oscillator is about 16 megahertz so the answer is is using the internal PLL phase look at loop its aim to multiply the frequency in order to reach the maximum desired one which is 168 168 megahertz in our case so before moving to the second part so let's download our datasheet so open a new page here and the first thing you have to know your name of your Development Board so in our case my development board is discovery MD stm32f4discovery board yep so we googled it here and we open the first link and here in the key feature here there's everything in your board for example the lead the digital microphone etc the first one is your microcontroller name so our case in our match result if the stm32f4 oh seven v CT 6 so we copy this and we paste it right here and we google it and here we open the first link and we select all here and we download this file the datasheet so waiting for it ok it's take a little bit time so we go to the normally we go to the page 18 I don't know maybe this will change in the next version but the page 18 here the five overview the STM f4o of a block diagram so here you're going to understand everything in I will see you I will show you in the second part here so this thing and one we go back here data sheet here we need a file here document for the clock I know where he is but we come in your search for it we put clock here and we this one clock up figuration tool for stm-4 etc etc so we open it here and we download this document the clock integration tool so here a useful one useful document to understand more how to manage the clock here's the schematic clock clock schematic I'm going to need this this table for the flash agency we see this in the second part so if you have another board for example just write the board's name for example the stm32f4 to nine discovery this one result as you know this with the big big screen so we open at the first link and then we look in for the microcontroller name here we copy this my current role and paste here and we couple the first link then we open the datasheet we go to page 18 the same as the previous one and we zoom in this is the block diagram for the stm32f4 2/7 here normally the same thing but there's some changes the maximum frequency is 180 180 etc more flash etc so that's all for this part if this tutorial was interesting please push the like button and subscribe and if you want to have this channel there's a link in the video description below and if you want to see the second part of this tutorial click on the right top corner see you there
Info
Channel: TizanaMenYo
Views: 66,918
Rating: undefined out of 5
Keywords: AHB, APB, bus, Microcontroller (Computer Processor), stmico, AMBA, ARM, Systemcore clock, STM32, setting up, ppm, parts-per million, crystal
Id: zkmk9uAMa04
Channel Id: undefined
Length: 17min 8sec (1028 seconds)
Published: Mon May 25 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.