{"id":531,"date":"2021-10-28T04:41:59","date_gmt":"2021-10-28T04:41:59","guid":{"rendered":"https:\/\/blog.embeddedexpert.io\/?p=531"},"modified":"2021-10-28T06:16:22","modified_gmt":"2021-10-28T06:16:22","slug":"changing-core-frequency-of-stm32f767-using-registers-only","status":"publish","type":"post","link":"https:\/\/blog.embeddedexpert.io\/?p=531","title":{"rendered":"Changing core frequency of STM32F767 using registers only"},"content":{"rendered":"\n<p>In this guide, we shall use registers to change the core frequency from default 16MHz to 216MHz (maximum for F767ZIT).<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"229\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/09\/depositphotos_107252360-stock-illustration-maximum-speed-logo-icon-300x229.jpg\" alt=\"\" class=\"wp-image-455\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/09\/depositphotos_107252360-stock-illustration-maximum-speed-logo-icon-300x229.jpg 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/09\/depositphotos_107252360-stock-illustration-maximum-speed-logo-icon-768x587.jpg 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/09\/depositphotos_107252360-stock-illustration-maximum-speed-logo-icon-750x573.jpg 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/09\/depositphotos_107252360-stock-illustration-maximum-speed-logo-icon-400x305.jpg 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/09\/depositphotos_107252360-stock-illustration-maximum-speed-logo-icon-250x191.jpg 250w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/09\/depositphotos_107252360-stock-illustration-maximum-speed-logo-icon.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/figure><\/div>\n\n\n\n<p>We shall use CubeMX to determine the values required to reach the 216MHz operation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Getting required settings from CubeMX<\/h2>\n\n\n\n<p>We start off by opening CubeMX and select your F7 chip (F767ZITx in my case).<\/p>\n\n\n\n<p>After that, select system core then RCC and set the High Speed Clock as Crystal\/Ceramic Resonator<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"982\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-1024x982.png\" alt=\"\" class=\"wp-image-533\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-1024x982.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-300x288.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-768x736.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-1536x1472.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-2048x1963.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-1150x1102.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-750x719.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-400x383.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.10.28-AM-250x240.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After that, open Clock Configuration tab and follow the following steps<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"474\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-1024x474.png\" alt=\"\" class=\"wp-image-534\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-1024x474.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-300x139.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-768x356.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-1536x711.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-2048x949.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-1150x533.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-750x347.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-400x185.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.15.37-AM-250x116.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>1. Set the crystal frequency to match yours (8MHz in my case)<\/li><li>2. Select HSE as PLL source MUX<\/li><li>3. Set HCLK to 216 and hit enter<\/li><\/ul>\n\n\n\n<p>Now write down the PLL_N, PLL_M and PLL_P values and also AHB1, APB1 and APB2 prescalers. In my case, I have those values:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#define PLL_M      4\n#define PLL_N      216\n#define PLL_P      2<\/pre><\/div>\n\n\n\n<p>After that head back to RCC and note the flash latency:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"968\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-1024x968.png\" alt=\"\" class=\"wp-image-535\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-1024x968.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-300x284.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-768x726.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-1536x1452.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-2048x1936.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-1150x1087.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-750x709.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-400x378.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.26.56-AM-250x236.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In my case, I need to flash latency to 7WS (8-CPU cycle).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Start configuring the clock<\/h2>\n\n\n\n<p>We start off by opening the project and open system_stm32f7xx.c file<\/p>\n\n\n\n<p>In line HSE_VALUE change the value from 25000000 to the one match match yours (8000000 in my case)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"203\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-1024x203.png\" alt=\"\" class=\"wp-image-536\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-1024x203.png 1024w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-300x59.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-768x152.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-1536x304.png 1536w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-2048x405.png 2048w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-1150x228.png 1150w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-750x148.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-400x79.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/Screen-Shot-2021-10-28-at-6.31.04-AM-250x49.png 250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now, in main file we shall declare a function to change as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void SysClockConfig(void)<\/pre><\/div>\n\n\n\n<p>It takes not argument and returns nothing.<\/p>\n\n\n\n<p>Inside the function we start defining the PLL_P, PLLM and PLL_N values<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">#define PLL_M      4\n#define PLL_N      216\n#define PLL_P      2<\/pre><\/div>\n\n\n\n<p>Now declare some variable to help us later<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\"> __IO uint32_t StartUpCounter = 0, HSEStatus = 0;<\/pre><\/div>\n\n\n\n<p>We start off by enabling external clock source as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">RCC-&gt;CR |= ((uint32_t)RCC_CR_HSEON);<\/pre><\/div>\n\n\n\n<p>Then we wait until the clock is ready, if it is not ready within 3000 counts, break the function and jump to error section:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">do\n  {\n    HSEStatus = RCC-&gt;CR &amp; RCC_CR_HSERDY;\n    StartUpCounter++;\n  } while((HSEStatus == 0) &amp;&amp; (StartUpCounter != 3000));<\/pre><\/div>\n\n\n\n<p>Check if the HSE is on<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">if ((RCC-&gt;CR &amp; RCC_CR_HSERDY) != RESET)\n  {\n    HSEStatus = (uint32_t)0x01;\n  }\n  else\n  {\n    HSEStatus = (uint32_t)0x00;\n  }<\/pre><\/div>\n\n\n\n<p>if activated, we continue configuring the clock<\/p>\n\n\n\n<p>We start off by enabling clock access to power interface as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">RCC-&gt;APB1ENR |= RCC_APB1ENR_PWREN;<\/pre><\/div>\n\n\n\n<p>Then we reset VOS which will force to mode three<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">PWR-&gt;CR1 &amp;= (uint32_t)~(PWR_CR1_VOS);<\/pre><\/div>\n\n\n\n<p>Now we set the AHB1,APB1 and APB2 prescaler as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">RCC-&gt;CFGR |= RCC_CFGR_HPRE_DIV1;\n      \n\n    RCC-&gt;CFGR |= RCC_CFGR_PPRE2_DIV2;\n    \n\n    RCC-&gt;CFGR |= RCC_CFGR_PPRE1_DIV4;<\/pre><\/div>\n\n\n\n<p>Then we configure the PLL as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">RCC-&gt;PLLCFGR = PLL_M | (PLL_N &lt;&lt; RCC_PLLCFGR_PLLN_Pos) | (((PLL_P &gt;&gt; 1) -1) &lt;&lt; RCC_PLLCFGR_PLLP_Pos) |\n                   (RCC_PLLCFGR_PLLSRC_HSE);<\/pre><\/div>\n\n\n\n<p>Now, we turn on the PLL and wait until it is on<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">RCC-&gt;CR |= RCC_CR_PLLON;\n\n    \n    while((RCC-&gt;CR &amp; RCC_CR_PLLRDY) == 0)\n    {\n    }\n   <\/pre><\/div>\n\n\n\n<p>Then we configure the flash latency to be 7WS (waiting state)<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\/* Configure Flash prefetch, Instruction cache, Data cache and wait state *\/\n    FLASH-&gt;ACR = FLASH_ACR_LATENCY_7WS;<\/pre><\/div>\n\n\n\n<p>We select the PLL as clock source <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">  \/* Select the main PLL as system clock source *\/\n    RCC-&gt;CFGR &amp;= (uint32_t)((uint32_t)~(RCC_CFGR_SW));\n    RCC-&gt;CFGR |= RCC_CFGR_SW_PLL;\n\n    \/* Wait till the main PLL is used as system clock source *\/\n    while ((RCC-&gt;CFGR &amp; (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL)\n    {;}<\/pre><\/div>\n\n\n\n<p>Hence, the full code as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">\nvoid SysClockConfig(void) \/\/set the core frequency to 216MHz\n{\n#define PLL_M      4\n#define PLL_N      216\n#define PLL_P      2\n\t\n__IO uint32_t StartUpCounter = 0, HSEStatus = 0;\n  \n\n  RCC-&gt;CR |= ((uint32_t)RCC_CR_HSEON);\n \n\n  do\n  {\n    HSEStatus = RCC-&gt;CR &amp; RCC_CR_HSERDY;\n    StartUpCounter++;\n  } while((HSEStatus == 0) &amp;&amp; (StartUpCounter != 3000));\n\n  if ((RCC-&gt;CR &amp; RCC_CR_HSERDY) != RESET)\n  {\n    HSEStatus = (uint32_t)0x01;\n  }\n  else\n  {\n    HSEStatus = (uint32_t)0x00;\n  }\n\n  if (HSEStatus == (uint32_t)0x01)\n  {\n \n    RCC-&gt;APB1ENR |= RCC_APB1ENR_PWREN;\n    PWR-&gt;CR1 &amp;= (uint32_t)~(PWR_CR1_VOS);\n\n\n    RCC-&gt;CFGR |= RCC_CFGR_HPRE_DIV1;\n      \n\n    RCC-&gt;CFGR |= RCC_CFGR_PPRE2_DIV2;\n    \n\n    RCC-&gt;CFGR |= RCC_CFGR_PPRE1_DIV4;\n\n\t\t\n    RCC-&gt;PLLCFGR = PLL_M | (PLL_N &lt;&lt; RCC_PLLCFGR_PLLN_Pos) | (((PLL_P &gt;&gt; 1) -1) &lt;&lt; RCC_PLLCFGR_PLLP_Pos) |\n                   (RCC_PLLCFGR_PLLSRC_HSE);\n\n\n    RCC-&gt;CR |= RCC_CR_PLLON;\n\n    \n    while((RCC-&gt;CR &amp; RCC_CR_PLLRDY) == 0)\n    {\n    }\n   \n    \/* Configure Flash prefetch, Instruction cache, Data cache and wait state *\/\n    FLASH-&gt;ACR = FLASH_ACR_LATENCY_7WS;\n\n    \/* Select the main PLL as system clock source *\/\n    RCC-&gt;CFGR &amp;= (uint32_t)((uint32_t)~(RCC_CFGR_SW));\n    RCC-&gt;CFGR |= RCC_CFGR_SW_PLL;\n\n    \/* Wait till the main PLL is used as system clock source *\/\n    while ((RCC-&gt;CFGR &amp; (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL)\n    {;}\n  }\n  else\n  { \/* If HSE fails to start-up, the application will have wrong clock\n         configuration. User can add here some code to deal with this error *\/\n  }\n\n\tSystemCoreClockUpdate();\n\t\n\t\n}\n\n<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">3. Validating Core Frequency:<\/h2>\n\n\n\n<p>In order to validate the core frequency, we shall use SysTick timer to generate interrupt at rate of 1KHz (each 1 millisecond) and enable clock to PORTA and set PA5 as output  as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">__disable_irq();\n\t\n\tSysTick-&gt;LOAD=216000-1;\n\tSysTick-&gt;VAL=0;\n\tSysTick-&gt;CTRL=7; \/\/0b00000111;\n\tRCC-&gt;AHB1ENR |=RCC_AHB1ENR_GPIOAEN;\n\tGPIOA-&gt;MODER|= GPIO_MODER_MODER5_0; \/\/PA5 as output\n\t__enable_irq();<\/pre><\/div>\n\n\n\n<p>in interrupt handler, we shall toggle PA5 as following:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csrc&quot;,&quot;theme&quot;:&quot;dracula&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;C&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;c&quot;}\">void SysTick_Handler(void){\nGPIOA-&gt;ODR^=GPIO_ODR_OD5;\n}\t\n<\/pre><\/div>\n\n\n\n<p>After compile and upload the code and probe PA5 we shall get the following:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"480\" src=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/DS1Z_QuickPrint1.png\" alt=\"\" class=\"wp-image-537\" srcset=\"https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/DS1Z_QuickPrint1.png 800w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/DS1Z_QuickPrint1-300x180.png 300w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/DS1Z_QuickPrint1-768x461.png 768w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/DS1Z_QuickPrint1-750x450.png 750w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/DS1Z_QuickPrint1-400x240.png 400w, https:\/\/blog.embeddedexpert.io\/wp-content\/uploads\/2021\/10\/DS1Z_QuickPrint1-250x150.png 250w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Since each division of the horizontal line is 500microseconds, and we are getting 2 division high and two division low, thats mean the on time 1 millisecond and 1 millisecond off which as we set it. Thats mean we successfully changed the core frequency from 16MHz to 216MHz. Now, you can get the full potential of your mcu.<\/p>\n\n\n\n<p>Happy coding<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we shall use registers to change the core frequency from default 16MHz to 216MHz (maximum for F767ZIT). We shall use CubeMX to determine the values required to reach the 216MHz operation. 1. Getting required settings from CubeMX We start off by opening CubeMX and select your F7 chip (F767ZITx in my case). [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,12],"tags":[],"class_list":["post-531","post","type-post","status-publish","format-standard","hentry","category-embedded-systems","category-stm32"],"_links":{"self":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/531"}],"collection":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=531"}],"version-history":[{"count":2,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/531\/revisions"}],"predecessor-version":[{"id":539,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=\/wp\/v2\/posts\/531\/revisions\/539"}],"wp:attachment":[{"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.embeddedexpert.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}