title: How to get STM32F446 running at 180 Mhz?
body: <p>I'm trying to get the STM32F446 running at full speed, following this tutorial: <a href="https://www.youtube.com/watch?v=GJ_LFAlOlSk&amp;t=826s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=GJ_LFAlOlSk&amp;t=826s</a> i did everything he does, but the clock speed of my timers is DEADLY slow, like literally, when blinking an LED with pre-scalar of 9 and ARR of 20, it is easily visible by eye.. Wt* am i doing wrong ?</p>
  <pre><code>void setup_clock(void)
  {
      // Enables HSE and waits until it is ready
      *RCC_CR |= (1 &lt;&lt; RCC_CR_HSEON);
      while (!(*RCC_CR &amp; (1 &lt;&lt; RCC_CR_HSERDY)));
  
      // Set the power enable clock and voltage regulator
      *RCC_APB1ENR |= (1 &lt;&lt; RCC_APB1ENR_PWREN);
      *PWR_CR |= PWR_CR_VOS(PWR_CR_VOS_SCALEM1);
  
      // Configure flash
      *FLASH_ACR = (1 &lt;&lt; FLASH_ACR_DCEN) | (1 &lt;&lt; FLASH_ACR_ICEN) | (1 &lt;&lt; FLASH_ACR_PRFTEN);
      *FLASH_ACR |= FLASH_ACR_LATENCY(5);
  
      // Configures HCLK, PCLK1, PCLK2
      *RCC_CFGR &amp;= ~RCC_CFGR_HPRE_MASK;
      *RCC_CFGR |= RCC_CFGR_HPRE(RCC_CFGR_HPRE_NODIV);    // HCLK 180Mhz
  
      *RCC_CFGR &amp;= ~RCC_CFGR_PPRE1_MASK;
      *RCC_CFGR |= RCC_CFGR_PPRE1(RCC_CFGR_PPRE1_DIV4);   // PCLK1 45Mhz
  
      *RCC_CFGR &amp;= ~RCC_CFGR_PPRE2_MASK;
      *RCC_CFGR |= RCC_CFGR_PPRE2(RCC_CFGR_PPRE2_DIV2);   // PCLK2 90Mhz
  
      // Configures the main PLL
      *RCC_PLLCFGR = RCC_PLLCFGR_PLLN(180) |
              RCC_PLLCFGR_PLLP(RCC_PLLCFGR_PLLP_2) |
              RCC_PLLCFGR_PLLR(2) |
              RCC_PLLCFGR_PLLM(4) |
              (1 &lt;&lt; RCC_PLLCFGR_PLLSRC);
  
      // Enable PLL
      *RCC_CR |= (1 &lt;&lt; RCC_CR_PLLON);
      while (!(*RCC_CR &amp; (1 &lt;&lt; RCC_CR_PLLRDY)));
  
      // Use PLL as clock source
      *RCC_CFGR &amp;= ~RCC_CFGR_SW_MASK;
      *RCC_CFGR |= RCC_CFGR_SW(RCC_CFGR_SW_PLL_P);
      while ((*RCC_CFGR &amp; RCC_CFGR_SWS_MASK) != RCC_CFGR_SWS(RCC_CFGR_SWS_PLL));
  
      // Sets the CLOCK Ready status LED
      *GPIO_ODR(STATUS_BASE) |= (1 &lt;&lt; STATUS_CLKREADY);
  }
  </code></pre>