2014-08-29 02:52 AM
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
2014-08-29 07:32 AM
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''
...
2014-08-29 08:22 AM
Thanks Clive1,
Will do ... Many Thanks John W