I am working on an STM32F407 Discovery Board. But I didn't solve my clock configuration problem. I want to 168 MHz working frequency and I get help from CubeMX Clock Configuration Manager. And this is my PLLCFGR Register value from CubeMX: 0x4405408. (I have problem with this register). Then I was copy paste all RCC registers to my CMSIS code. This is my clock configuration code:
RCC->CFGR = 0x4008940A; //MCO2 Source is PLLI2S (4), HSE Divided by 8 for RTC (8), APB2 Divided by 2 for 84Mhz, APB1 Divided by 4 for 42 Mhz
RCC->CR = 0x0F0B6783; //PLL, PLLI2S, HSE, CSS ON
RCC->PLLCFGR = 0x04405408; //PLLQ 4 (4), PLLSRC = HSE (4), PLLP 2 (0), PLLN 336 (54), PLLM 8 (8)
RCC->PLLI2SCFGR = 0x50003C00; //PLLI2SR 5 (5), PLLI2SN 240 (3C)
But I can't read the same values from SFRs menu in Atollic. All registers are correct but the PLLCFGR register value is 0x04405419. This issue effects my clock speed, peripheral speed etc. I want to set PLLM bits to 8 but I read 19. So I get less speed then I want, because PLLM bits decide PLL input clock division. How can I solve this register problem?
When doing the clock configuration, you can't just load the registers with their final values. You need to follow some logical order and satisfy the limits mentioned in the reference manual. You must also consider the flash memory wait states.
Here is an example code to run STM32F407 at 48 MHz, using 8 MHz HSE. I feel lazy to modify & test it for 168 MHz, but this should give you the idea and a starting point.