cancel
Showing results for 
Search instead for 
Did you mean: 

SystemClock_Config issue on STM32f769NI

dhanaraj shanmugam
Associate II
Posted on October 23, 2017 at 12:52

Hi All,

Due to CPU package change, I tried to change the CPU from Keil configuration. But the project does not work. So when I check the problem part, it is SystemClock_Config() where I am configuring the sysclk. 

STM32f769NI based project is not working while stm32f769BI based project is working without any issue. I have not changed anything but the CPU. 

To experiment a bit, I changed the PLL_M and PLL_N to a different value but generate same sysclk then the project works but only half the speed(Ex: 500msec timer runs 1 sec interval).

here below my SystemClock_Config function.

/**

* @brief System Clock Configuration

* The system Clock is configured as follow :

* System Clock source = PLL (HSE)

* SYSCLK(Hz) = 200000000

* HCLK(Hz) = 200000000

* AHB Prescaler = 1

* APB1 Prescaler = 4

* APB2 Prescaler = 2

* HSE Frequency(Hz) = 8000000

* PLL_M = 4

* PLL_N = 200

* PLL_P = 2

* PLL_Q = 2

* VDD(V) = 3.3

* Main regulator output voltage = Scale1 mode

* Flash Latency(WS) = 6

* @param None

* @retval None

*/

static void SystemClock_Config(void)

{

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_OscInitTypeDef RCC_OscInitStruct;

RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

__HAL_RCC_PWR_CLK_ENABLE();

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

/* 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.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 4;

RCC_OscInitStruct.PLL.PLLN = 200;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = 2;

if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

Error_Handler();

}

/* activate the OverDrive to reach the 200 Mhz Frequency */

if(HAL_PWREx_EnableOverDrive() != HAL_OK)

{

Error_Handler();

}

/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2

clocks dividers */

RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | 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_6) != HAL_OK)

{

Error_Handler();

}

/* Select PLLSAIP as USB clock source 48MHz =((HSE/PLLM)*PLLSAIN)/PLLSAIP.

Set LTDC clock to 12MHz = (((HSE/PLLM)*PLLSAIN)/PLLSAIP)/PLLSAIDivR.

Select CLK48 as SDMMC1 as clock source. */

PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_SDMMC1|RCC_PERIPHCLK_CLK48 | RCC_PERIPHCLK_UART7;

PeriphClkInitStruct.PLLSAI.PLLSAIN = 96;

PeriphClkInitStruct.PLLSAI.PLLSAIR = 4;

PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2;

PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV4;

PeriphClkInitStruct.PLLSAIDivQ = 1;

PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4;

PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48SOURCE_PLLSAIP;

PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_CLK48;

PeriphClkInitStruct.Uart7ClockSelection = RCC_UART7CLKSOURCE_PCLK1;

  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)

  {

    Error_Handler();

  }

}

Sorry if anything wrong in my post since it is my first one.

3 REPLIES 3
dhanaraj shanmugam
Associate II
Posted on October 26, 2017 at 04:19

Any insights please? 

Posted on October 26, 2017 at 05:40

Does it 'work' if you use the HSI as the clock source?

Have you exported internal clocks via the PA8 (MCO) pin?

Does it get stuck in the Error_Handler()

Have you compared any of the RCC or peripheral registers between the two designs?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
dhanaraj shanmugam
Associate II
Posted on October 31, 2017 at 03:42

Sorry for the late reply.

To make it simpler, I copied an RTX blink program with 25MHZ clock. Since my hardware is 8MHZ, I just reconfigured that portion. 

When I tried to configure the CCR to achieve HCLK = 200MHZ, It always goes to Hardfault_handler or Can not stop debugger state whether the clock source is HSI or HSE.

Using MCO2 on PC9 pin, I am able to see the PLLCLK is generating 200MHZ. with the AHB prescaller is set to 1, HCLK is supposed to be same as PLLCLK.

I compared the working CPU RCC registers and not working CPU RCC registers. It is more or less same(Same in the necessary section). 

Just to try, I reduced the clock to 150MHZ by changing the PLLM and PLLN, I am able to see my LED blinking. And I am able to see the LED blinking when I comment out the OS functions with 200mhz sysclk.

And one new update is that if I enable MicroLIB option then I am able to see the LED blinking even with the OS functions. I do not have much experience with RTX hence i'm clueless about the issue.