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

LPCOMP sampling rate

Hi,

I want to sample lpcomp result at 50us, I'm doing so by using the following statements and set/clear a gpio based on the lpcomp result:

nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_SAMPLE); lpcomp_result = nrf_lpcomp_result_get();

This is done in 50us TIMER interrupt.

LPCOMP configuration : My LPCOMP configuration

We observe some differences in the gpio waveform when an external comparator chip (LM2901N) is used instead of the internal LPCOMP. The observed waveforms are attached below.(some samples seem to be skipped while using the LPCOMP)

waveform using LPCOMP: image description waveform using external comparator chip: image description

Can we sample the LPCOMP at 50us rate? What are the limitations of LPCOMP? Is there a specific way to achieve this?

Parents
  • I tested this with a PWM input signal. Note that according to basic sampling theorems, you need a minimum sampling frequency that is 2 times higher than the maximum frequency of the input signal.

    Have you tried increasing the sampling rate?

    Again, you don't need to use a TIMER for this. The LPCOMP does automatically detection when the signal goes below/over your reference ( LPCOMP can generate separate events on rising and falling edges of a signal), so you don't need to periodically sample the state from a timer interrupt, the LPCOMP can generate the events itself when the input signal changes.

Reply
  • I tested this with a PWM input signal. Note that according to basic sampling theorems, you need a minimum sampling frequency that is 2 times higher than the maximum frequency of the input signal.

    Have you tried increasing the sampling rate?

    Again, you don't need to use a TIMER for this. The LPCOMP does automatically detection when the signal goes below/over your reference ( LPCOMP can generate separate events on rising and falling edges of a signal), so you don't need to periodically sample the state from a timer interrupt, the LPCOMP can generate the events itself when the input signal changes.

Children
No Data
Related