cancel
Showing results for 
Search instead for 
Did you mean: 

System Tick Problem

blue_dolphin1987
Associate II
Posted on February 24, 2014 at 06:27

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;
}

9 REPLIES 9
frankmeyer9
Associate II
Posted on February 24, 2014 at 08:55

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.

blue_dolphin1987
Associate II
Posted on February 24, 2014 at 09:32 Hi fm , i have the following symbols defined (KEIL)

USE_STDPERIPH_DRIVER,STM32F429_439xx

Is this enough to configure the clock value ? or there is more to it ?
frankmeyer9
Associate II
Posted on February 24, 2014 at 11:03

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.

troy1818
Senior
Posted on February 24, 2014 at 13:19

Hi,

Also Make sure that the variable 

SystemCoreClock 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,

/rygelxvi

Posted on February 25, 2014 at 02:01

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.h
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
blue_dolphin1987
Associate II
Posted on February 25, 2014 at 03:13 Hi i am new to STM32 development . I am using STM32F4xx_DSP_StdPeriph_Lib_V1.3.0 as i would like to test out 427 as well so i did not useSTM32F429I-Discovery_FW_V1.0.1 . Insystem_stm32f4xx.c HSE is defined as 25 Mhz .

*=============================================================================
* 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.
Posted on February 25, 2014 at 03:59

Thankfully the math is fairly pedestrian, #define

PLL_M

8
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
blue_dolphin1987
Associate II
Posted on February 25, 2014 at 04:13

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 using

STM32F4xx_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.

frankmeyer9
Associate II
Posted on February 25, 2014 at 08:40

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...).