Closed katyo closed 4 years ago
I tried to set correct PLLMUL but it doesn't help.
Strange, I have no problems with project in C where I setup clock in a next way:
RCC_CR |= (RCC_CR_HSEON | RCC_CR_CSSON);
for (; !((RCC_CR & (RCC_CR_HSERDY))); );
RCC_CFGR = (RCC_CFGR & ~(RCC_CFGR_SW | RCC_CFGR_HPRE | RCC_CFGR_PPRE | RCC_CFGR_PLLMUL | RCC_CFGR_PLLSRC))
| (RCC_CFGR_SW_HSE | RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE_DIV1 | RCC_CFGR_PLLMUL_MUL6 | RCC_CFGR_PLLSRC_HSE);
FLASH_ACR |= (FLASH_ACR_LATENCY_1WS);
RCC_CR |= (RCC_CR_PLLON);
for (; !((RCC_CR & (RCC_CR_PLLRDY))); );
RCC_CFGR = (RCC_CFGR & ~(RCC_CFGR_SW))
| (RCC_CFGR_SW_PLL);
I've created a patch that has the extra logic for determining the divider when HSI is the source. It's in my branch https://github.com/pigrew/stm32f0xx-hal/tree/pllsrc
I still need to test it (though it does pass the CI checks)... I'll create a PR once I'm more confident in it.
Usually I clock my precision devices from external 8MHz crystal and it fails to work here. There is my setup:
There infinite busy-loop occurs on PLL ready flag awaiting. To exclude hardware problems I tried to load code from other project in C with similar setup and it works as expected. It seems PLL multiplier calculation is wrong because in case of using HSE as a clock source according to datasheet the input frequency does not divided by two alike a case when HSI is used. I may mistake but that my debugger says:
Unexpectedly HSE turned off and the PLLMUL is 10 (x12 multiplier) when 4 (x6) is expected.