AnsweredAssumed Answered

STM32F405RG MCO Problem

Question asked by paintedman on Sep 8, 2014
Latest reply on Sep 10, 2014 by paintedman
Hi! I have a problem with MCO output (pin PC6) on STM32F405RG. I configured it with STM32CubeMX to generate about 36 MHz but I see only 8.97 MHz. How should I calculate correct PLLI2SN and PLLI2SR to get 36 MHz?

Configuration in STM32CubeMX

01.void SystemClock_Config( void ) {
02.    RCC_ClkInitTypeDef RCC_ClkInitStruct;
03.    RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
04.    RCC_OscInitTypeDef RCC_OscInitStruct;
05. 
06.    __PWR_CLK_ENABLE();
07. 
08.    __HAL_PWR_VOLTAGESCALING_CONFIG( PWR_REGULATOR_VOLTAGE_SCALE1 );
09.    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
10.    RCC_OscInitStruct.HSIState = RCC_HSI_ON;
11.    RCC_OscInitStruct.HSICalibrationValue = 6;
12.    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
13.    RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
14.    RCC_OscInitStruct.PLL.PLLM = 16;
15.    RCC_OscInitStruct.PLL.PLLN = 336;
16.    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
17.    RCC_OscInitStruct.PLL.PLLQ = 4;
18.    HAL_RCC_OscConfig( &RCC_OscInitStruct );
19. 
20.    RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
21.    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
22.    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
23.    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
24.    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
25.    HAL_RCC_ClockConfig( &RCC_ClkInitStruct, FLASH_LATENCY_5 );
26. 
27.    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S;
28.    PeriphClkInitStruct.PLLI2S.PLLI2SN = 258;       // 258
29.    PeriphClkInitStruct.PLLI2S.PLLI2SR = 7;
30.    HAL_RCCEx_PeriphCLKConfig( &PeriphClkInitStruct );
31.}

Outcomes