defining the clocks based on HSE in STM32F407

Thread Starter

yef smith

Joined Aug 2, 2020
755
Hello, i am building the clock setting based on HSE in STM32FG14 using the link bellow.
1.At first i am setting the 16th bit of the CR register of RCC and wating till 17th bit will be ready
2.enabling power
3.voltage regulator setting
4.FLASH ACR settings
5.prescaling setting,using the diagram of cube MX

HSE ranges between 4MHz to 16MHz cube MX allows us to set the TOP HSE frequency in the GUI,but in teh register there is no such option as shown in the code and register printscreen registers bellow.

using the code i wrote bellow of using purely registers,What is the HSE frequency?
How do i set its exact value?
Thanks.
https://www.st.com/resource/en/refe...-arm-based-32-bit-mcus-stmicroelectronics.pdf


Code:
#include "stm32f407xx.h"

uint16_t counter;
uint16_t k;

void sysclockconfig(void)
{
    //ENABLE HSE and wit for it till it becomes ready
RCC->CR|=RCC_CR_HSEON;
while(!(RCC->CR&RCC_CR_HSERDY));
    //Power enable
    RCC->APB1ENR|=RCC_APB1ENR_PWREN;
    //voltage regulator setting
    PWR->CR|=PWR_CR_VOS;
  
    //Flash control register
    FLASH->ACR=FLASH_ACR_ICEN|FLASH_ACR_DCEN|FLASH_ACR_PRFTEN|FLASH_ACR_LATENCY_5WS;
  
  
}

int main(void)
{
  
  
    while(1)
    {
      
    }
}

1616183401821.png
1616184528430.png
1616186265293.png

1616187894534.png

1616189445481.png
 

Attachments

Top