Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. void SystemClock_Config(void)
  2. {
  3. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  4. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  5.  
  6. /** Initializes the CPU, AHB and APB busses clocks
  7. */
  8. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
  9. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  10. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  11. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  12. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_OFF;
  13. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
  14. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
  15. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) // Вот здесь зависает
  16. {
  17. Error_Handler();
  18. }
  19. /** Initializes the CPU, AHB and APB busses clocks
  20. */
  21. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  22. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  23. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
  24. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  25. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  26. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  27.  
  28. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  29. {
  30. Error_Handler();
  31. }
  32. HAL_RCC_MCOConfig(RCC_MCO, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1);
  33. }
  34.  
  35. /* Enable the main PLL. */
  36. __HAL_RCC_PLL_ENABLE();
  37.  
  38. /** @brief Macro to enable the main PLL.
  39. * @note After enabling the main PLL, the application software should wait on
  40. * PLLRDY flag to be set indicating that PLL clock is stable and can
  41. * be used as system clock source.
  42. * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
  43. */
  44. #define __HAL_RCC_PLL_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = ENABLE)
  45.  
  46. /* Infinite loop */
  47. /* USER CODE BEGIN WHILE */
  48. while (1)
  49. {
  50. /* USER CODE END WHILE */
  51.  
  52. /* USER CODE BEGIN 3 */
  53. HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_3);
  54. HAL_Delay(1);
  55. }
  56. /* USER CODE END 3 */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement