Skip to main content
Anas Nashawaty
Associate
June 23, 2018
Question

3MHZ pulse counter with trigger output

  • June 23, 2018
  • 5 replies
  • 1420 views
Posted on June 23, 2018 at 13:27

Hi, i'm totaly new to stm32 actually i have been looking for a solution to test some motion control output the case is:

i need to measure number of pulse that motion give it at speed of around 3mhz and when the number is equal to the set value that set to the stm32f4 it give a pulse out as a trigger without any latency , i don't have any board yet but i think 'discovery' stm32f4 could handle it, if there is any body have tried such idea or have any segregation or example code could help a lot thank you for reading my Post.

Anas

    This topic has been closed for replies.

    5 replies

    henry.dick
    Associate II
    June 24, 2018
    Posted on June 24, 2018 at 21:30

    easy:

    1) set up a timer to count up an external input;

    2) load up the timer value to -desired pulses;

    3) set up interrupt on overflow;

    4) in the isr, do things you want.

    it can be done with a downcounter, or output compare as well.

    Anas Nashawaty
    Associate
    June 24, 2018
    Posted on June 24, 2018 at 22:29

    thank you

    henry.****

    for your fast response,

    could you please advice witch board could be powerful and good for starting? and please some sample code if possible for the case?, is it possible to use another input signal to save the count in so realtime without any latency, i mean save the count when exactly the input signal is acquire like ISR or so?

    thank you again.

    Anas

    Tesla DeLorean
    Guru
    June 24, 2018
    Posted on June 24, 2018 at 23:13

    The use of '3 MHz' and  'without any latency' gets complicated.

    You could have a TIM in external count mode and toggle another channel using the hardware. ie IF TIM2->CNT == TIM2->CCR1 THEN TIM2_CH1 ^= 1;

    If you start involving interrupts you're going to hit a ceiling at a few hundred KHz

    You might want to consider if your task lends itself to the use of a CPLD or FPGA, where you control the timing and the latency, and can support MHz repetition.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..