8 posts / 0 new
Last post
satya247
TIMER

Hi,

can you please explain this code

prescalar = (uint16_t)((SystemCoreClock/2)/13107)-1;

is systemcoreclock is 168MHz / 84 MHz / 8 MHz ?

we divided 65535 into 5 to get 13107, how 13107 is 1 sec? i couldn't understood that part
very confusing for me, can you please elaborate.

if SystemCoreClock = 168 MHZ i am getting prescalar as 6407.7891.

are there any furthur calculation using prescalr value to get accuare 1 sec.

Many thanks
Satya

satya247
Can you please let me know is

Can you please let me know is there any difference between stm32f401 and 407 decovery board
because I wrote the code exactly as you wrote but i used Timer 4
I am not getting exactly 1 sec .

I would appreciate , I you explain me.

Msny thanks
Satya

lgvadm
Hi Satya,

Hi Satya,
Yes there is difference between stm32f401 and 407 discovery board. The microcontroller is different. Hence you need to configure the timer with different settings as compare to what i have shown in the video. Although the coding lines will be same but the numbers in the configuration will be different.

lgvadm
STM32F407VGT microcontroller

STM32F407VGT microcontroller has maximum 168 MHz frequency. But i think your microcontroller has maximum 84 MHz clock frequency.
I havn't gone through with the stm32f401 discovery board yet but still try with this line:

PrescalarValue = (uint16_t)((SystemCoreClock)/13107)-1;

and also you need to make sure that your System clock is running at 84 MHz.

satya247
mAY i KNOW WHERE TO CHECK MY

mAY i KNOW WHERE TO CHECK MY CLOCK IS RUNING AT 84 mhZ PLEASE.

satya247
FOUND IT THANKS

FOUND IT
THANKS

satya247
Hi Anupam,

Hi Anupam,

Can you please make a video of Timer caluclations
I couldn't understood those caluclations.

I know it is hard to make a video.
I dont mind paying for the video.

if it is hard to make a video can you please point me in aright direction (any book showing all the caluclation )

I really appreciate your help

Many thanks
Satya

lgvadm
Hi Satya

Hi Satya

You asked this above:

"can you please explain this code
prescalar = (uint16_t)((SystemCoreClock/2)/13107)-1;
is systemcoreclock is 168MHz / 84 MHz / 8 MHz ?
we divided 65535 into 5 to get 13107, how 13107 is 1 sec? "

Let me explain you:
in this line :
prescalar = (uint16_t)((SystemCoreClock/2)/13107)-1;
here i have written 13107 because i want the timer clock to be 13107 Hz. That means in 1 second it will create 13107 ticks. Hence it will take exactly 1 second time for the timer counter to reach from 1 to 13107.

If you still need any help, i would suggest you to watch my video few times and i will start making clear to you. Or you can ask me at the contact us page.