Facebook
From Rude Curlew, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 329
  1. void RCC_Configuration(void)
  2. {
  3.         ErrorStatus HSEStartUpStatus;
  4.         /* RCC system reset(for debug purpose) */
  5.         RCC_DeInit();
  6.  
  7.         /* Enable HSE */
  8.         RCC_HSEConfig(RCC_HSE_ON);
  9.  
  10.         /* Wait till HSE is ready */
  11.         HSEStartUpStatus = RCC_WaitForHSEStartUp();
  12.  
  13.         if(HSEStartUpStatus == SUCCESS)
  14.         {
  15.                 /* Enable Prefetch Buffer */
  16.                 FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
  17.  
  18.                 /* Flash 2 wait state */
  19.                 FLASH_SetLatency(FLASH_Latency_2);
  20.  
  21.                 /* HCLK = SYSCLK */
  22.                 RCC_HCLKConfig(RCC_SYSCLK_Div1);
  23.  
  24.                 /* PCLK2 = HCLK */
  25.                 RCC_PCLK2Config(RCC_HCLK_Div1);
  26.  
  27.                 /* PCLK1 = HCLK/2 */
  28.                 RCC_PCLK1Config(RCC_HCLK_Div2);
  29.  
  30.                 /* PLLCLK = 8MHz * 9 = 72 MHz */
  31.                 RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
  32.  
  33.                 /* Enable PLL */
  34.                 RCC_PLLCmd(ENABLE);
  35.  
  36.                 /* Wait till PLL is ready */
  37.                 while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
  38.                 {
  39.                 }
  40.  
  41.                 /* Select PLL as system clock source */
  42.                 RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
  43.  
  44.                 /* Wait till PLL is used as system clock source */
  45.                 while(RCC_GetSYSCLKSource() != 0x08)
  46.                 {
  47.                 }
  48.         }
  49.  
  50.         /* Enable peripheral clocks --------------------------------------------------*/
  51.  
  52.         /* Enable GPIOA, GPIOB, and GPIOC clocks */
  53.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE);
  54.  
  55.         PWR_BackupAccessCmd(ENABLE);
  56. }
  57.  

Replies to Untitled rss

Title Name Language When
Re: Untitled Tinct Marmoset text 5 Years ago.