cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F405RG MCO Problem

3deemon
Associate II
Posted on September 08, 2014 at 14:35

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 correctPLLI2SN andPLLI2SR to get 36 MHz?

https://copy.com/MRClPwP0vLq3yqiI


void
SystemClock_Config( 
void
) {

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

RCC_OscInitTypeDef RCC_OscInitStruct;


__PWR_CLK_ENABLE();


__HAL_PWR_VOLTAGESCALING_CONFIG( PWR_REGULATOR_VOLTAGE_SCALE1 );

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

RCC_OscInitStruct.HSIState = RCC_HSI_ON;

RCC_OscInitStruct.HSICalibrationValue = 6;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;

RCC_OscInitStruct.PLL.PLLM = 16;

RCC_OscInitStruct.PLL.PLLN = 336;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = 4;

HAL_RCC_OscConfig( &RCC_OscInitStruct );


RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

HAL_RCC_ClockConfig( &RCC_ClkInitStruct, FLASH_LATENCY_5 );


PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S;

PeriphClkInitStruct.PLLI2S.PLLI2SN = 258; 
// 258

PeriphClkInitStruct.PLLI2S.PLLI2SR = 7;

HAL_RCCEx_PeriphCLKConfig( &PeriphClkInitStruct );

}

#stm32f4 #mco
4 REPLIES 4
Posted on September 08, 2014 at 17:09

Yeah, well PLLIS2 isn't going to come out of MCO1 (PA8), at least according to RM0090

You could get 33.6 MHz out using 168 MHz DIV5

Your inquiry with respect to HAL code might be better served on the other forum. I don't see any code here configuring the MCO pin(s), or how 36 MHz would come out based on the settings.

PC6 is I2S2_MCK, PC9 is MCO2

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
3deemon
Associate II
Posted on September 09, 2014 at 11:04

Oh, sorry! Of course I meant I2S2_MCK (before posting I read many threads on this forum and mixed pin name). So, according to settings in STM32CubeMX I should get on I2S2_MCK (PC6) 857 MHz, but I get 8.97 MHz. STM32CubeMXconfigured PLLI2S like this:

PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S;
PeriphClkInitStruct.PLLI2S.PLLI2SN = 258; 
PeriphClkInitStruct.PLLI2S.PLLI2SR = 7;
HAL_RCCEx_PeriphCLKConfig( &PeriphClkInitStruct );

What could be the reason?
Amel NASRI
ST Employee
Posted on September 09, 2014 at 18:22

To output PLLI2S clock, you have to use MCO2 (PC9).

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

3deemon
Associate II
Posted on September 10, 2014 at 13:03

Thank you very much, it works! 

It would be good to see warning in STM32 software that I could not get this frequency on PC6 pin.