Guest User

Untitled

a guest
Apr 19th, 2020
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. RCC->CR |= RCC_CR_HSEON;
  2. while (!(RCC->CR & RCC_CR_HSERDY)){};
  3.  
  4. FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_LATENCY;
  5.  
  6. RCC->CFGR &= ~RCC_CFGR_SW; //clear SW bits
  7. RCC->CFGR |= RCC_CFGR_SW_0; //SYSCLK is HSE
  8. while (!(RCC->CFGR & RCC_CFGR_SWS_0)){};
  9.  
  10. RCC->CR &= ~RCC_CR_PLLON; //PLL OFF
  11.  
  12. RCC->CFGR &= ~RCC_CFGR_HPRE; //AHB = 1;
  13. RCC->CFGR &= ~RCC_CFGR_PPRE2;
  14. RCC->CFGR &= ~RCC_CFGR_PPRE1;
  15. RCC->CFGR |= RCC_CFGR_PPRE2_2; //APB2 = 2;
  16. RCC->CFGR |= RCC_CFGR_PPRE1_0 | RCC_CFGR_PPRE1_2; // APB1 = 4;
  17.  
  18. RCC->PLLCFGR &= ~RCC_PLLCFGR_PLLM;
  19. RCC->PLLCFGR &= ~RCC_PLLCFGR_PLLN;
  20. RCC->PLLCFGR &= ~RCC_PLLCFGR_PLLQ;
  21. RCC->PLLCFGR |= RCC_PLLCFGR_PLLM_2 | RCC_PLLCFGR_PLLM_3; //PLLM = 12
  22. RCC->PLLCFGR |= RCC_PLLCFGR_PLLN_4 | RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_8; //PLLN = 336;
  23. RCC->PLLCFGR &= ~RCC_PLLCFGR_PLLP; // PLLP = 2;
  24. RCC->PLLCFGR |= RCC_PLLCFGR_PLLQ_2; //PLLQ = 4;
  25.  
  26. RCC->PLLCFGR |= RCC_PLLCFGR_PLLSRC_HSE;
  27. RCC->CR |= RCC_CR_PLLON;
  28. while (!(RCC->CR & RCC_CR_PLLON)){};
  29.  
  30.  
  31. RCC->CFGR &= ~RCC_CFGR_SW; //clear SW bits
  32. RCC->CFGR |= RCC_CFGR_SW_1; //SYSCLK is PLL
  33. while (!(RCC->CFGR & RCC_CFGR_SWS_1)){};
Advertisement
Add Comment
Please, Sign In to add comment