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
  • Are you using the SoftDevice/BLE at the same time? Does it make any difference if you increase the IRQ priority ?

    Here some code I used to test this, and it worked fine. I'm here sampling at 20 us. Signal input at pin 4, and lpcomp result output at pin 28. I used reference voltage Supply 4/8 when I tested this.


    Is there a reason why you need to sample every 50us? Note that you can get an interrupt every time the signal crosses your voltage reference. That way you don’t need to pool/sample the result every 50 us... Also if the signal changes faster than you are pooling, you will lose data. So using the LPCOMP interrupt is generally preferred over sampling in a timer interrupt.

Reply
  • Are you using the SoftDevice/BLE at the same time? Does it make any difference if you increase the IRQ priority ?

    Here some code I used to test this, and it worked fine. I'm here sampling at 20 us. Signal input at pin 4, and lpcomp result output at pin 28. I used reference voltage Supply 4/8 when I tested this.


    Is there a reason why you need to sample every 50us? Note that you can get an interrupt every time the signal crosses your voltage reference. That way you don’t need to pool/sample the result every 50 us... Also if the signal changes faster than you are pooling, you will lose data. So using the LPCOMP interrupt is generally preferred over sampling in a timer interrupt.

Children
No Data
Related