I think flash wait states isn't directly related in that way
I ran my script
viewtopic.php?t=78
and got one entry like this
FHSE: 8 m: 1 n: 30 p: 4 (RCC_PLLP_DIV4) q: 5 fusb: 48.0 fcpu: 60.0
but for this
Fvco = 8 * 30 / 1 = 240 Mhz
That is still pretty high. I think sometimes PLL fails if Fvco is too high.
That PLLP from the script is PLLR in this case - it is intended to be SYSCLK.
That script is based on F4 where PLLP goes to SYSCLK.
for stm32g0b1, PLLR (SYSCLK) output is : HSE * n / m / r = 8 * 30 / 1 / 4 = 60 Mhz
maybe try
Code: Select all
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 8;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV1; // this goes to ADC and I2S, 60 Mhz, I'm not sure if that is too high, if it is try DIV2
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV5; // 48mhz this goes to USB
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4; // Fvco 240 mhz / 4 ~ SYSCLK 60 Mhz
^ for this one above I think there is still one more multiplexer to configure to tell usb to use PLLQ instead of HSI48.
If you use HSI48 instead, then I'd guess you can 'ignore' the PLLQ divisor.
e.g. you can use lower Fvco rather than to try to push it up e.g. you may like to use Fvco = 64 Mhz instead
e.g.
Code: Select all
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
RCC_OscInitStruct.PLL.PLLN = 8;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV1; // this goes to ADC and I2S, 60 Mhz, I'm not sure if that is too high, if it is try DIV2
// RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV1; // this goes to USB, ignored use HSI48
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV1; // Fvco 64 mhz / 1 ~ SYSCLK 64 Mhz
generally I prefer to run USB on the crystal, less drift, less issues. Usb is fussy about 12 MHz and typically requires it to be exact.