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

Low power pulse width measurement with LPCOMP

Hi,

I'd like to be able to use an event from the LPCOMP to sample the RTC (either to a peripheral's register, or to a memory address), so I can measure pulse widths without waking the processor.

Is there any way of doing this? It seems like EasyDMA might be an option, but as far as I can tell it only appears to be built into peripherals, not usable as a standalone memory transfer device.

Ideally I'd just use a timer, but it seems they have to run off the high speed oscillator, not the low speed one? Or is it possible to use the TICK event from the RTC to increment a timer? Is that efficient, or does it then need to start the high speed oscillator 32k times a second?

thanks!

Parents
  • Hi,

    I believe the best way to do any pulse width measurement is to use GPIOTE+TIMER(+RTC)+PPI. For code examples and more information, please see this, this and this post.

  • Hi, sorry for the duplicate issue (the devzone website timed out while posting).

    Those posts appear to suggest using the timer to count pulses, and the RTC to then trigger a task to copy the pulse count out? Obviously that works well for reasonably fast pulses, but if they are slow you need to wait a long time to get any reasonably accurate response.

    Is it actually possible to have a low power timer that runs at 32kHz (using RTC TICK)? Or does the high speed oscillator have to be on to be able to use the timer, making that a really bad idea?

  • The HF clock/oscillator don't need to be running for this, it will work using the LF clock(32kHz). The RTC TICK is an event that is generated for every counter increment in the RTC. (I don’t think this event is useful in what you are trying to do).

    Both GPIOTE and LPCOMP can be used to generate separate events on rising and falling edges of a signal, if you want to measure the pulse width from when the signal crosses a specific threshold voltage, then use the LPCOMP. If you only need to measure how long the signal is logical high or low, then use GPIOTE.

    Then on the desired event(EVENTS_IN for GPIOTE, or EVENTS_UP,DOWN,CROSS for LPCOMP), trigger the RTC START task to start the measurement. On the next event(event that indicates the signal is high/low again), trigger the RTC STOP task. The result will then be available in the RTC COUNTER register.

  • Thanks! I was using RTC0 and RTC1 but it looks like RTC2 is actually free so this would be absolutely perfect.

Reply Children
No Data
Related