2014-02-23 09:27 PM
Hi ,
I am using STM32F429 discovery. The system tick is suppose to produce an interrupt every 1ms. However, i have gotten 3.12ms instead. Did i make a mistake ?int main(void)
{
Init_LEDPanel();
// Pulsing at 1msec per interrupt
SysTick_Config(SystemCoreClock/1000);
while (1){}
}
void SysTick_Handler(void)
{
GPIOE->ODR ^= GPIO_Pin_4;
}
2014-02-23 11:55 PM
I suggest to check the HSE clock definition 'HSE_VALUE' in the corresponding header file. 3.12ms/1ms is damn close to 25/8, meaning, a wrong default frequency for the external (quartz) clock.
BTW, the best solution is to provide the correct define in the project (make) settings, and not changing the header.2014-02-24 12:32 AM
USE_STDPERIPH_DRIVER,STM32F429_439xx
Is this enough to configure the clock value ? or there is more to it ?
2014-02-24 02:03 AM
Is this enough to configure the clock value ? or there is more to it ?
Yes, there is more to do. I use other discovery boards, with different MCUs. But it's usually the stm32f<xxx>.h one in the ../Libraries/CMSIS/Device/ST/STM32Fxxx/Include folder. Check the 'HSE_VALUE' define there. It uses to define a default value, if you do not provide your own, matching your quartz frequency.
2014-02-24 04:19 AM
Hi,
Also Make sure that the variableSystemCoreClock is correct according to your board frequency. It is not set automatically to my knowledge. E.g. configuring the MCU at max freq. you should have 168000000 as value here.
Regards,/rygelxvi2014-02-24 05:01 PM
For the F429I the top speed is nominally 180 MHz, ST often hard codes the thing, I've had it compute via the PLL defines in a couple of examples where I change those settings frequently.
You should review the files in the TEMPLATE project, as this usually represent a good starting point, and are where project/ board specific modifications can be made without messing with the code within the library itself. HSE_VALUE is defined as 8000000 here: STM32F429I-Discovery_FW_V1.0.1\Projects\Template\stm32f4xx_conf.h2014-02-24 06:13 PM
*=============================================================================
* Supported STM32F42xxx/43xxx devices
*-----------------------------------------------------------------------------
* System Clock source | PLL (HSE)
*-----------------------------------------------------------------------------
* SYSCLK(Hz) | 180000000
*-----------------------------------------------------------------------------
* HCLK(Hz) | 180000000
*-----------------------------------------------------------------------------
* AHB Prescaler | 1
*-----------------------------------------------------------------------------
* APB1 Prescaler | 4
*-----------------------------------------------------------------------------
* APB2 Prescaler | 2
*-----------------------------------------------------------------------------
* HSE Frequency(Hz) | 25000000
*-----------------------------------------------------------------------------
* PLL_M | 25
*-----------------------------------------------------------------------------
* PLL_N | 360
*-----------------------------------------------------------------------------
* PLL_P | 2
*-----------------------------------------------------------------------------
* PLL_Q | 7
*-----------------------------------------------------------------------------
* PLLI2S_N | NA
*-----------------------------------------------------------------------------
* PLLI2S_R | NA
*-----------------------------------------------------------------------------
* I2S input clock | NA
*-----------------------------------------------------------------------------
* VDD(V) | 3.3
*-----------------------------------------------------------------------------
* Main regulator output voltage | Scale1 mode
*-----------------------------------------------------------------------------
* Flash Latency(WS) | 5
*-----------------------------------------------------------------------------
* Prefetch Buffer | ON
*-----------------------------------------------------------------------------
* Instruction cache | ON
*-----------------------------------------------------------------------------
* Data cache | ON
*-----------------------------------------------------------------------------
* Require 48MHz for USB OTG FS, | Disabled
* SDIO and RNG clock |
*-----------------------------------------------------------------------------
*=============================================================================
Is HSE supposed to be 8Mhz ? If yes how can i change it ?
Previously there is a excel from ST that supports the modifying of clock speed but it seem to support the 407 series.
2014-02-24 06:59 PM
Thankfully the math is fairly pedestrian, #define
PLL_M
8
2014-02-24 07:13 PM
Hi ,
I found my problem using after suggestion from clive1 and fm (BIG thank you). Here is a summary , in case newbie like me came across the same problem/mistake . I am usingSTM32F4xx_DSP_StdPeriph_Lib_V1.3.0not
STM32F429I-Discovery_FW_V1.0.1 .
The former library supports all variant of stm32f4 this explains my choice. As it is a rather generic library to adapt in to STM32F429I-DISCO first you have to modify \Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h In line 121
#if !defined (HSE_VALUE)
/* CHANGE THE BELOW TO YOUR HSE FREQ FOR DISCOVERY IT IS 8000000 ORIGINAL VALUE IS 25000000*/ #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ Then move to system_stm32f4xx.c Line 252/* CHANGE PLL_M TO 8 ORIGINAL VALUE IS 25*/
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */ #define PLL_M 8 /* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */ #define PLL_Q 7 That all. Hope this helps someone. Thanks for all help provided.2014-02-24 11:40 PM
I didn't follow this thead last afternoon, since the whole STM32 sub-forum had a serious problem - at least here on my site ...
To comment on this: The header CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h is not really intended for modification. A better way would be to add a define for HSE_VALUE to the project settings, to override the default. Otherwise, you might need to change this file forth and back for different boards and projects. The system_stm32fxxx.c files are tailored to a specific board, and better copied into the project folder (if I remember correctly here, it is generated by ST's clock configuration tool...).