cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 Time base Interrupt

waheed901
Associate II
Posted on February 16, 2017 at 11:39

Hi,

I need Help regarding time base.

I found one of the example and tried to modify that for STM32 F4 Discovery board.

I want to count number of external pulses by using TIM4 in 1.13 ms. So the time base is configured to generate interrupt after each 1.13 ms (as the read_me file states). the code is generating interrupt but it is not after 1.13 ms. can any body help me in this matter. I have attached the files for your review. 

Thanks in Advance  

#clive #clive1 #stm32-stm32f4
14 REPLIES 14
waheed901
Associate II
Posted on February 20, 2017 at 06:20

the HE_Value (as defined in stm32f4xx.h)  

#if !defined (HSE_VALUE)

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

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

#endif /* HSE_VALUE */

I have checked the value is 7A1200 (8000000)

The PLL setting 

/************************* PLL Parameters *************************************/

/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */

#define PLL_M 25

#define PLL_N 336

/* SYSCLK = PLL_VCO / PLL_P */

#define PLL_P 2

/* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */

#define PLL_Q 7
waheed901
Associate II
Posted on February 20, 2017 at 06:29

Can anyone tell me 

how can I know the frequency (or time period) attached with counter of TIM3  in STM32f4Discovery? If there is any command .

How can I get how many interrupts are generated (interrupt counter)?

can anyone refer me to some example please?

waheed901
Associate II
Posted on February 20, 2017 at 08:55

I tried to use 

 if (SysTick_Config(RCC_Clocks.SYSCLK_Frequency / 1000))

by using RCC_Clocks.SYSCLK_Frequency the rate is 1ms 

while for 

if (SysTick_Config(SystemCoreClock / 1000))

 the rate is 3.1 ms.

can anyone tell me what could be wrong... can't I get 1ms rate by using systemcoreclock??

Posted on February 20, 2017 at 14:25

 ,

 ,

25 / 8 = 3.125?

♯ define PLL_M 25 // You are not clocking at 25 MHz, shouldn't this be 8 ?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
waheed901
Associate II
Posted on February 21, 2017 at 03:06

you are right, 

Thank you very much for the help and support. 

this was the problem.