Pulse Width Counter using peripheral only

We have a hall sensor with pwm output encoding the information in the duty cycle of pwm. Now we would like to read the duty cycle without the use of an interrupt, but solely using the nrf52840 timer peripheral. 

It seems impossible to find an example on how to have the timer start counting on a rising edge, stop counting at the falling edge and placing the counter value in the CC register. That is actually all we need. We do not need an interrupt once the CC register has been updated nor do we need each single CC register value. We would like the OS to be in control of when a value is required, but it should be up to date, once we need the pulse with value.

Can you provide an example for this?

Thanks

Martin

Parents Reply Children
  • Hi Martin

    That is great news Slight smile

    For full disclosure, since I had limited time to make the example I didn't take the time to properly implement it as a Zephyr library. Ideally you would want to integrate the example with the Kconfig and device tree architecture, rather than hard coding everything in the application. 

    I might try to do this later, but I don't know when I will have more time to look at it. 

    Best regards
    Torbjørn

Related