# Pulse Counting

**URL:** <https://community.sparkfun.com/t/pulse-counting/3168>\
**Category:** MicroMod\
**Tags:** msp\
**Created:** [November 24, 2006, 5:41pm UTC](https://community.sparkfun.com/t/pulse-counting/3168 "2006-11-24T17:41:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![clirakis](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@clirakis](https://community.sparkfun.com/u/clirakis)\
**Post date:** [November 24, 2006, 5:41pm UTC](https://community.sparkfun.com/t/pulse-counting/3168/1 "2006-11-24T17:41:28Z")

</div>

I have a sensor which produces a square wave of varying frequency on its output.

I would like to capture this value. I am using the eZ430-F2013. Based on the document I thought I could input a this value on P1.0 and setup Timer 2A to use TACLK. This doesn’t appear to work.

I had another thought, but the chip is nott exactly designed for this. Use the XIN pin

My third tought is just to make an interrupt on P1.0 and count them, seems like a waste of resources.

Any thoughts? Has anyone else tried to do pulse counting?

Chris

---

<div class="post-metadata">

**Author:** ![Philba](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@Philba](https://community.sparkfun.com/u/Philba)\
**Post date:** [November 24, 2006, 10:07pm UTC](https://community.sparkfun.com/t/pulse-counting/3168/2 "2006-11-24T22:07:26Z")

</div>

why not just configure a pin for input and interrupt. then use the timer to time the period between interrupts?

---

<div class="post-metadata">

**Author:** ![Eduardo](https://avatars.discourse-cdn.com/v4/letter/e/6a8cbe/32.png) [@Eduardo](https://community.sparkfun.com/u/Eduardo)\
**Post date:** [November 25, 2006, 1:20pm UTC](https://community.sparkfun.com/t/pulse-counting/3168/3 "2006-11-25T13:20:20Z")

</div>

A good way to measure frequency is to connect the signal to a pin that triggers a timer capture irq on each rising edge f.e. In the irq service you can read the value that was copied into the capture register. Store it to a variable. At the next irq you can subtract the old capture value from the new one. Now you got the length of the period of your sqaure wave.

TimerA runs always uninterrupted counting up on ACLK.

This can be beefed up with time out and overflow recognition, couting absolute number of pulses, debouncing etc.

Eduardo

---

<div class="post-metadata">

**Author:** ![clirakis](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@clirakis](https://community.sparkfun.com/u/clirakis)\
**Post date:** [November 25, 2006, 1:50pm UTC](https://community.sparkfun.com/t/pulse-counting/3168/4 "2006-11-25T13:50:23Z")

</div>

Hi Eduardo,

That is what I ended up doing. It appears to work quite well. Now I’d like to figure out a way to pump the result back to the host computer over the USB port.

Next part of the project.

Thank you both for your help.

Chris
