2011-12-06 01:43 AM
I tried to build examples from stm32f4discovery_fw package for stm32f4-dicovery board. And I have a incorrect CPU timing settings.
Some examples. I tried to make TIM_PWM_Output example with 2.5kHz PWM. /* Compute the prescaler value */ PWM_pulse_freq = 1680000; PrescalerValue = (uint16_t) ((SystemCoreClock /2) / PWM_pulse_freq) - 1; /* Time base configuration */ TIM_TimeBaseStructure.TIM_Period = ( PWM_pulse_freq / 2500 ) - 1; TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; CCR1_Val = TIM_TimeBaseStructure.TIM_Period >> 1; TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); In this case I have 832Hz output signal. I tried to make simple FreeRTOS example. I used task where one of leds toggled with and vTaskDelay-functions called. Configured delay time is 100ms - real time delay 311ms. I used Eclipse IDE, project configured as described . As far as I understand problem is in HSE/HSI settings. What kind of settings I need to change/set? Why software examples (used default settings) does not worked as described? #stm32f4-discovery-hse-hsi-timing2011-12-06 10:57 AM
Why software examples (used default settings) does not worked as described?
Probably because the examples are set up for the typical prototyping board with a 25 MHz HSE. The F4 Discovery has an 8 MHz HSE. See flasch.franz post 20 Nov on this forum for more explanation and a fix. Cheers, Hal Baird2011-12-07 01:58 AM
OK
I redifined HSE_VALUE in stm32f4xx_conf.h with following code#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 */ but program doesn't work properly. I tried to include in program part of STM32F4-Discovery_FW_V1.1.0\Project\Demonstration code RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); but doesn't help. Where is clock initialization in demonstration programm? Only one thing help me:SystemCoreClockUpdate(); But I need to know right way to correct clock initialization of demo board.2011-12-07 04:23 PM
The clocks are set up by the startup code, prior to calling main(). The routine called in Keil is SystemInit()
Generally I would recommend cloning projects so you get at the critical meta-data and options that are not always obvious when building one from scratch. It should be possible to examine the code generated to understand what/how things are being configured. Keil has example projects for the STM32F4-Discovery board, and the firmware library should have project files for the major tool chains.