Manual Clock Configuration Issue
Hello,
first let me start this post by mentioning that I'm still very much a beginner.
I'm writing my own abstraction layer functions for the N657X0.
While running my clock_config() function, I ran into an issue that I don't know how to fix. The function works as follows:
- reset RCC->CR, CRGR1, CFGR2
- enable MSI and wait for MSI ready bit
- set CPU & SYS clock source to MSI and wait for clock source confirmation bits
- disable all other oscillators and all PLL
- reset RCC->HSICFGR
- configure HSI
- enable HSI and wait for HSI ready bit
- set CPU & SYS clock source to HSI and wait for clock source confirmation bits
- disable MSI
- reset RCC->MSICFGR
- configure MSI
- enable/disable oscillators (if HSIEN=0 then MSIEN=1 and vice-versa)
- reset RCC->ICxCFGR
- configure ICx
- reset RCC->PLLxCFGRx
- configure PLLx
- enable PLLx and wait for PLLx lock ready bit
- check CPU and SYS clock source selection
- check if source is actually active by checking the corresponding ready bit again
- select CPU and SYS clock sources (IC1 for CPU and IC2 for SYS)
- wait for clock source confirmation bits <- endless wait loop fault here!
The fault occurs at the very last link in the chain. I checked the clock source ready bit before when setting the sources to MSI/HSI and it worked then but not at the end. Is my clock_config() logic sound at all?
