cancel
Showing results for 
Search instead for 
Did you mean: 

defining the clocks based on HSE in STM32F407

Nbkjh.1
Associate II

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 the register there is no such option as shown in the code 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

#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)
    {
      
    }
}

2 REPLIES 2

It is determined by the external part you have chosen in your design​.

Code does not look to select HSE.

R​est of software understands speed via HSE_VALUE define.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Nbkjh.1
Associate II

"stm32f407xx.h" doesnt contain HSE_VALUE variable.

I know that cubemx gui some how allows the HSE to be from 8-20Mhz but how?

where is the HSE_vale located?