AnsweredAssumed Answered

Oscillator configuration error on SW 1.3

Question asked by elgarbe on Aug 8, 2015
Latest reply on Aug 8, 2015 by elgarbe
Hi, I've been working with SW 1.2 and integrated cube MX on my custom board. It has a stm32f411re with a TI audio codec.
I could make a project on cubemx, on it I configure the occillator to HSE 12MHz crystal. I've import that project on SW and everithing works ok.

Now I want to work without cubemx. So I've started a new workspace, create a new project, select my uC and add hal library as shared external library.
At this point I have just a startup function and a main function.
Then I copy the SystemClock_Config from generated cubemx and paste on this new project. 

void SystemClock_Config(void)
    RCC_OscInitTypeDef RCC_OscInitStruct;
    RCC_ClkInitTypeDef RCC_ClkInitStruct;
    RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
    RCC_OscInitStruct.HSEState = RCC_HSE_ON;
    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
    RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
    RCC_OscInitStruct.PLL.PLLM = 7;
    RCC_OscInitStruct.PLL.PLLN = 196;
    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
    RCC_OscInitStruct.PLL.PLLQ = 4;
    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
    HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S;
    PeriphClkInitStruct.PLLI2S.PLLI2SN = 271;
    PeriphClkInitStruct.PLLI2S.PLLI2SM = 12;
    PeriphClkInitStruct.PLLI2S.PLLI2SR = 2;

I compile and run this code but I have the problem that the resulting frequency is 50% more than expected... I have I2C configured to 100KHz and measure 150KHz on SCL. I have 44khz I2S and I measure 66KHz on WS... same code on cubemx generated project run ok....
any ideas?