SHARE
TWEET

Untitled

a guest Sep 20th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void SystemClock_Config(void)
  2. {
  3.     RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  4.     RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  5.     RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  6.  
  7.     /** Configure the main internal regulator output voltage
  8.      */
  9.     __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
  10.     /** Initializes the CPU, AHB and APB busses clocks
  11.      */
  12.     RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_MSI;
  13.     RCC_OscInitStruct.LSIState = RCC_LSI_ON;
  14.     RCC_OscInitStruct.MSIState = RCC_MSI_ON;
  15.     RCC_OscInitStruct.MSICalibrationValue = 0;
  16.     RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
  17.     RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  18.     if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  19.     {
  20.         Error_Handler();
  21.     }
  22.     /** Initializes the CPU, AHB and APB busses clocks
  23.      */
  24.     RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  25.             |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  26.     RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
  27.     RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  28.     RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  29.     RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  30.  
  31.     if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  32.     {
  33.         Error_Handler();
  34.     }
  35.     PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
  36.     PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
  37.     if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  38.     {
  39.         Error_Handler();
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top