cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 Ext Crystal

john239955_st
Associate III
Posted on August 29, 2014 at 11:52

Dear Community,

I am using the STM32F407 for the first time and require to set up CAN into a Peak CAN Tx/Rx Module.

I have an external crystal of 8 MHz, the file <stm32f4xx.h> appears not to set the HSE_VALUE to 8000000.

#if !defined  (HSE_VALUE)

 

#define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */

 

#endif /* HSE_VALUE */

 

 

 

I have set #define HSE_VALUE ((unit32_t) 8000000) but this appears to be reset back to 25000000.

 

 

With the 8 MHz crystal CAN error occur, fitting a 25 MHz crystal all is OK, but need to understand why this error occurs, as I may need to change crystal frquencies.

 

 

Any help would be appreciated.

 

 

Regards .... John W

 

 

 

2 REPLIES 2
Posted on August 29, 2014 at 16:32

The Discovery boards use 8 MHz sources, they generally set HSE_VALUE in stm32f4xx_conf.h, a project unique file. The alternative is to pass it as a define on the compiler command line. These both would ensure that all source would see the same define. The stm32f4xx_conf.h file is pulled in via stm32f4xx.h

...
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F40x_CONF_H
#define __STM32F40x_CONF_H
#if defined (HSE_VALUE)
/* Redefine the HSE value; it's equal to 8 MHz on the STM32F4-DISCOVERY Kit */
#undef HSE_VALUE
#define HSE_VALUE ((uint32_t)8000000)
#endif /* HSE_VALUE */
/* Includes ------------------------------------------------------------------*/
/* Uncomment the line below to enable peripheral header file inclusion */
#include ''stm32f4xx_adc.h''
#include ''stm32f4xx_can.h''
...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
john239955_st
Associate III
Posted on August 29, 2014 at 17:22

Thanks Clive1,

Will do ...

Many Thanks

John W