STM32L43KC: Changing Clock Frequency?
Hey guys, just having the hardest of times changing clock frequency to 80MHz for the system clock and 43MHz for the ADC clock. Every time I try it seems the writing function to registers gets disabled such as RCC->AHB2ENR trying to enable GPIOA and ADC clock enables.
The weirdest thing is I tried it even with the HAL pre-generated code and there's no difference in performance. I am running a digital filter and its still takes the same time as it was on 4MHz assuming the HAL worked in changing the clock frequency. Any Ideas?
Here's the code:
void initClock(){
void initClock(){
RCC->CR |= RCC_CR_MSIRGSEL; // Enable: MSIRANGE in CR
RCC->CR |= RCC_CRMSIRANGE_6;
RCC->PLLCFGR &= ~(1<<12); //
RCC->PLLCFGR |= ((1<<13) | (1<<11)); // PLLN = 40
RCC->PLLCFGR |= (1<<0); // PLLSRC = MSI
RCC->PLLSAI1CFGR |= (1<<25); //PLLSAI1R = 4
RCC->PLLSAI1CFGR &= ~(1<<12);
RCC->PLLSAI1CFGR |= ((1<<8) | (1<<9) | (1<<11) | (1<<13)); //PLLSAI1N = 43
RCC->CR |= (1<<24); // Enable: PLL
while(((RCC->CR) & (1<<25)) == 0); //Wait till PLL is ready
RCC->CR |= (1<<26); // Enable: PLLSAI1
while(((RCC->CR) & (1<<27)) == 0); // Wait till PLLSAI1 is ready
RCC->PLLCFGR |= (1<<24); // Enable: PLLREN Goes into System Clock
RCC->PLLSAI1CFGR |= (1<<24); //Enable: PLLSAI1REN Goes into ADC
RCC->CFGR |= ((1<<1) | (1<<0)); // Switches to the PLL ClCK source
}