Skip to main content
eixp12
Associate
March 30, 2012
Question

Prescaler and timers

  • March 30, 2012
  • 4 replies
  • 831 views
Posted on March 30, 2012 at 10:17

How can I configure

the

Port A

prescaler

to read

every 5

seconds.

What is the

formula

that is used

?

Is there a

document that explains how

I set

the timers

?

    This topic has been closed for replies.

    4 replies

    Tesla DeLorean
    Guru
    March 30, 2012
    Posted on March 30, 2012 at 14:50

    I've always found reading the TECHNICAL MANUALS to be quite adequate

    Where

      TIM_TimeBaseStructure.TIM_Prescaler = X - 1;

      TIM_TimeBaseStructure.TIM_Period = Y - 1;

    UpdateRate = (TIMCLK / X) / Y;

    For 5 Seconds, and 72 MHZ, you must factor 72000000 * 5 into two 16-bit values (ie less than 65536)

    = 5 * 72000000

    = 360000000

    = 36000 * 10000

    Prescale = 36000 - 1;

    Period = 10000 - 1;

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    eixp12
    eixp12Author
    Associate
    March 30, 2012
    Posted on March 30, 2012 at 18:05

    The TIMClK is the value of the Sysclock or AHPB1 stm32f4discovery?

     Then the prescaler must always be less than 65536 right.

    When we multiply 5 * 72000000 = 360000000 which means?

    Tesla DeLorean
    Guru
    March 30, 2012
    Posted on March 30, 2012 at 18:39

    TIMCLK will depend on which TIM you use, and the clock settings on your system. I assumed 72 MHz based on how the STM32F1xx chips work.

    On an STM32F4 it's presumably 168 MHz or 84 MHz. And you also have a couple of 32-bit period counters.

    Assuming 5 seconds at 168 MHz, we have

    = 5 * 168000000

    = 42000 * 20000

    I don't presume to know what settings you have, refer to the clock tree and settings.

    You are trying to count the number of clock ticks over 5 seconds. Realistically you could have the interrupt at a more frequent rate, and then count off 5 seconds.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    eixp12
    eixp12Author
    Associate
    March 30, 2012
    Posted on March 30, 2012 at 18:55

    thank you

    I'll try to implement