2023-01-10 06:42 AM
Hello,
I have two different clock setting and only one of them works - but I have no idea why?
The only difference is the PLLM and PLLN value:
RCC_OscInitStruct.PLL.PLLM = 25; // 5 NOT OK
RCC_OscInitStruct.PLL.PLLN = 432; // 160 NOT OK
Would appreciate any hints...
See clock seting below, I have a 25MHz ext. Crystal:
NOT working clock setting:
CC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
HAL_StatusTypeDef ret = HAL_OK;
/*!< Supply configuration update enable */
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /* PWR set to LDO for the STM32H750B-DISCO board */
/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 5;
RCC_OscInitStruct.PLL.PLLN = 160;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLQ = 4;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
if(ret != HAL_OK)
{
Error_Handler();
}
/* Select PLL as system clock source and configure bus clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
if(ret != HAL_OK)
{
Error_Handler();
}
Working clock setting:
CC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
HAL_StatusTypeDef ret = HAL_OK;
/*!< Supply configuration update enable */
HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /* PWR set to LDO for the STM32H750B-DISCO board */
/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 432;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLQ = 4;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
if(ret != HAL_OK)
{
Error_Handler();
}
/* Select PLL as system clock source and configure bus clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
if(ret != HAL_OK)
{
Error_Handler();
}
2023-01-10 07:29 AM - edited 2023-11-20 08:21 AM
Hello @pk84 ,
I advice you try with STM32CubeMX to set Timing via Clock Configuration. It's more easier for you to manage your clock tree.
For your example :
RCC_OscInitStruct.PLL.PLLM = 5;
RCC_OscInitStruct.PLL.PLLN = 160;
Foued
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.
2023-01-11 01:16 AM
Thank you. I already use CubeMx (Code is generated from CubeMx).
I forgot to mention what exactly is not working.
It is a simple LED blinking program (see code below) with two LEDs.
One LED on Pin PF10 and the other one on Pin PC13.
If I select 5/160 only the PC13 LED is blinking, if I select 25/432 both LEDs are blinking.
This is very strange for me... I still have no idea about the root cause or how to find it.. :( ??
LED blinking program:
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_Delay(600);
//HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
//HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
//HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);
//HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_6);
HAL_GPIO_TogglePin(GPIOF, GPIO_PIN_10);
//HAL_Delay(500);
//HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_8);
}
2023-01-11 01:24 AM
with the Debugger both LEDs seems to work with 5/160...
So do I have a PCB, Layout or Crystal problem??
I used the same (power) circuit diagram as from the STM32H750 Discovery board....
See below video-link of DEBUG with the two different clock settings.
Hope somebody can help me here?
25/432 clock setting (OK - but maybe also not ok??)
https://drive.google.com/file/d/1auRE17ihgOZkdqk6qohLRDti8w7o1hnI/view?usp=share_link
5/160 clock setting (NOT OK)
https://drive.google.com/file/d/1auVbjhQM_t4_ZGWx7c-mFSc364bO0vQO/view?usp=share_link
2023-01-12 03:05 AM
No hints? Where/How can I get professional support?
2023-01-12 05:27 AM
> I used the same (power) circuit diagram as from the STM32H750 Discovery board
So your board is not the STM32H750 Discovery? Then what is it?
2023-01-12 05:30 AM
It is a custom board.
Power circuit, crystal and other "important" settings are according the STM32H750 Disco schematic...
2023-01-13 06:53 AM
:( ?
2023-01-13 07:15 AM
Hello @pk84 ,
The GPIOC and GPIOF are mapped on the same bus and no problems with the STM32H750 Disco
Try to verify your PCB .
Foued
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.
2023-01-13 07:42 AM
Well, I don't see anything blinking with 600 ms in any video.
Maybe check your SysTick generation, which is used by HAL_Delay (I think).
But you see that the "working version" runs on a 216 MHz clock, the other version with 400 MHz ?