This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Measure frequency

Hi all,

I want to use nRF51822 (s110) to measure the frequency (0 to 5kHz) of a signal connected to an analog input. Other posts (like this) show that a good way to implement this is to use a combination of:

  • A timer and a counter. The first one lasts during the whole measurement (for example 1 second). The second one is defined as a counter.
  • LPCOMP to check if the signal goes up/down a defined threshold
  • PPI defined so as every threshold detected by LPCOMP increases the counter. Therefore, when the measurement finishes, you can get the frequency of the signal by dividing the counter between the duration of the measurement.

This works well when the signal lasts for the whole duration of the measurement. However, this is not the case for me. My high-frequency signal (sound generated by a microphone) lasts only for 100-150ms every second.

This causes that the frequency calculated is much lower than the real one. Therefore, other ambient sounds (which have lower frequency but more duration) can be mixed with the high-frequency signal I want to detect.

Is there a way to detect this high frequency among the rest of ambiental sound? I have though to use a timer that measures the time between thresholds and keep it in memory. Therefore, at the end of the measurement I can get the different frequencies during the whole process and detect high-frequency sounds.

Unfortunately I don't know how make this done. I would need to add something like DMA for writing the value of the timer in memory in each threshold. Could somebody help me?

Thank you!

Related