2020-11-02 01:49 AM
Hi,
I am trying to set SysClock to 216MHz using stm32f769xx.h
I have no access to MCO pins, so for testing I am trying to blink a led every second. ARR and PSC values to achieve it will confirm if I am to desired SysClock frecuency (Blink led using timer is working with Sysclock to 16MHz using HSI)
This is what I have:
// Configuring main internal regulator output voltage
RCC->APB1ENR |= RCC_APB1ENR_PWREN;
PWR->CR1 |= 0x03<<PWR_CR1_VOS_Pos;
//-- Configuring main oscillator
// HSI On
RCC->CR |= RCC_CR_HSION;
while (!(RCC->CR & RCC_CR_HSIRDY)) {};
// HSI Calibration Trimming value
RCC->CR |= 0x10<<RCC_CR_HSITRIM_Pos;
// -- Configuring PLL
//PLL Off
RCC->CR &= ~RCC_CR_PLLON;
// HSI as PLL source
RCC->PLLCFGR &= ~(0x01<<RCC_PLLCFGR_PLLSRC_Pos);
// Configure PLL M, N, P,Q for 216 MHz
RCC->PLLCFGR |= 8<<RCC_PLLCFGR_PLLM_Pos;
RCC->PLLCFGR |= 216<<RCC_PLLCFGR_PLLN_Pos;
RCC->PLLCFGR |= 2<<RCC_PLLCFGR_PLLP_Pos;
RCC->PLLCFGR |= 2<<RCC_PLLCFGR_PLLQ_Pos;
//PLL On
RCC->CR |= RCC_CR_PLLON;
// Enable Over-Drive Mode
PWR->CR1 |= PWR_CR1_ODEN;
while (!(PWR->CSR1 & PWR_CSR1_ODRDY)) {};
PWR->CR1 |= PWR_CR1_ODSWEN;
while (!(PWR->CSR1 & PWR_CSR1_ODSWRDY)) {};
// Set Flash latency
FLASH->ACR |= 7<<FLASH_ACR_LATENCY_Pos;
while (!(RCC->CR & RCC_CR_PLLRDY)) {};
// -- Configuring Clock
// Select the PLL as the system clock source.
RCC->CFGR |= (RCC_CFGR_SW_PLL);
while (!(RCC->CFGR & RCC_CFGR_SWS_PLL)) {};
// Configure Clock preescalers
RCC->CFGR |= RCC_CFGR_HPRE_0;
RCC->CFGR |= RCC_CFGR_PPRE1_2;
RCC->CFGR |= RCC_CFGR_PPRE2_1;
For testing, I am using TIM6 with ARR = 63999 and PSC=3374.
However, I think I have not successfully configured SysClock because of blinking led period is not 1s.
Any idea of what I am missing?
Kind Regards,
Rafa