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

Can we implment PWM Analyzer on SDK 11?

I need to implement a PWM analyzer. I looked at the example in SDK 6 and it's fairly easy to follow. When I tried it, it doesn't look like GPIOTE handler gets called frequently enough. Is there a better recommendation to calculate duty cycle other than using GPIOTE that will do a good job sensing the rise and drop?

  • Great, things looking well on my side. When it comes to sense rises and drops, I'll have to use NRF_GPIOTE_POLARITY_TOGGLE right? There is no way where I can use 2 events, hi to lo and lo to hi, on one pin? My concern would be identifying if it is a rise or if it's a drop when using toggle.

  • You are right, you cannot get events for both low-to-high and high-to-low transitions on one GPIO pin using GPIOTE. What you can do is to use one pin with the comparator instead, as there you have separate events for low-to-high and high-to-low transitions. Alternatively you can use two GPIO pins. Using GPIOTE with polarity toggle can be a problem, as you cannot be certain about the polarity.

    Of course if you are happy with doing parts of the measurements in software, as the example in SDK 6, this is less of an issue. However you will have less accurate measurements, particularly when higher priority interrupts occur while measuring (as discussed earlier in this thread).

    There may be a smarter way of doing this that has not come to my mind. It will be interesting to see how you solve it.

Related