This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

F2837xD Input Counter



I have simple pulses coming into an external pin.  I want the microcontroller to count a specific number of pulses and then give me an interrupt when this happens.

Is the eCAP module the correct peripheral to use for this?  I can't seem to find any examples of how to implement anything close to this.

  • Yes eCAP would be the right peripheral to capture external inputs and count the pulses based on the pulse edge specification. Please look for the ecap_capture_pwm example.

    Thanks

    Noah

  • If you'd rather have the counting be done without software help, the eQEP peripheral may be best. 

    Something like:
    Set the eQEP module in "Direction count" (CLK/DIR) mode. Connect CLK to the signal you want to count and tie DIR high.
    Set QPOSMAX to be the amount of pulses you want to count before the interrupt occurs. 
    Configure the PCO signal to generate an interrupt for you.


    Thank you,
    Brett