Skip to main content
crthorne
Associate
Oct 19, 2009 8:55 PM UTC
Question

Slow timer with pulse

Posted on October 19, 2009 at 22:55

Slow timer with pulse

    This topic has been closed for replies.

    2 replies

    crthorne
    crthorneAuthor
    Associate
    May 17, 2011 11:26 AM UTC
    Posted on May 17, 2011 at 13:26

    I need to use a timer on the STM3210E-EVAL card to produce a signal with a 480 Hz repetition rate. I need the signal to be normally high and go low for a period (anything between 1 microsecond and 1/480 Hz is OK) every 480Hz.

    I would prefer to use Timer2 CH2 on PA1.

    Can anyone give me some guidance?

    Thanks

    tomas23
    Visitor II
    May 17, 2011 11:26 AM UTC
    Posted on May 17, 2011 at 13:26

    Hi, look at library examples about the timers, this is clearly the PWM mode. Please check the Reference Manual, too, for the timer description.

    In general, you have to know your TIM_CK freq. (72 MHz?), the period (=2.08333 ms) and resolution 1 us?)

    You can see that in one period you have 150 000 ticks of timer. While timer has 16 bits only, I recommend to apply divider 3 (you get 50 000 ticks per period) and the PWM resolution will be in multiple tens of nanoseconds.

    To port the code from TIM1 to TIM2, you need to modify the GPIO pins used in the examples.