2018-11-16 12:52 AM
Hi,
I have a Nucleo STM32F767ZI with a X-Nucleo-PLC01A1 and a test application that cyclically switches ON/OFF the outputs .
All works fine when I use HSI, with Output LEDs that stay solid during ON state.
If I use High Speed Clock (in Cube MX, PCC->HSE->Crystal/Ceramic Resonator), LEDs blink with high freq, as a sort of refresh.
As you can see , I set both HSE & HSI to 16MHz, so working frequency are the same.
Can you help me or give me any suggestions?
This is HSI Clock:
while this is HSE:
Thanks and best regards,
Mario
Solved! Go to Solution.
2018-11-16 02:24 AM
By default that board is fed with 8 MHz external clock from ST-Link. If You haven't modified the board, then the correct code is:
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.PLL.PLLM = 4;
2018-11-16 01:27 AM
This is what Cube supposedly wants to do.
Have you checked what actually happens, like the pulse frequency on the ouputs, or the system clock frequency ?
2018-11-16 02:11 AM
The system appears as it is "slowed down", a "5s. delay" takes approx 10-11s.
It seems as a sort of prescaler was applied, but I'm no able to find where...
Code for HSE is:
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
/**Configure the main internal regulator output voltage */
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/**Initializes the CPU, AHB and APB busses clocks */
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 = 8;
RCC_OscInitStruct.PLL.PLLN = 216;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Activate the Over-Drive mode*/
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Initializes the CPU, AHB and APB busses clocks */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|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;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure the Systick interrupt time */
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
/**Configure the Systick */
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
That is virtually the same for HSI (with HSE substitute by HSI).
2018-11-16 02:24 AM
By default that board is fed with 8 MHz external clock from ST-Link. If You haven't modified the board, then the correct code is:
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.PLL.PLLM = 4;
2018-11-16 06:16 AM
Thanks!! It works!!
So, setting F7 HSE clock @16MHz caused a sort of erroneus clock syncronism, infact system took double time to execute code!