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

Setup Input Capture in Zephyr

Hello, can you please provide more information and instructions on how we configure the input capture on nrf52840 dev board using zephyr? All sample examples only cover pwm output. I have a square signal that I would like to capture the time associated with its rising and falling edges. According to the zephyr PWM driver documentation, I could do this by configuring the capture feature using the following function:

static inline int pwm_pin_configure_capture(const struct device *dev, uint32_t pwm, pwm_flags_t flags, pwm_capture_callback_handler_t cb, void * user_data)

In the function, I would use PWM_CAPTURE_TYPE_BOTH and PWM_CAPTURE_MODE_CONTINUOUS flags. However, it is not clear to me how do I configure which pin is the capture pin. I am assuming I need to create a DTS overlay file but not sure about the content. Thank you. 

Parents
  • Thank you for the info. Any plans to enable the input capture feature of the zephyr PWM driver?

    Meanwhile, we have created the code to capture the time associated with input signal transitions referencing the nrfx example you shared. We got it working, but it is not exactly what we want. We need to capture the time of both the rising and falling edges of the same input signal. It looks like we can only generate one event per GPIO pin. The event can be either HItoLO, LOtoHI, or TOGGLE. The toggle event would have worked except when we route it through a PPI channel to a timer capture register; either transition will update the capture register. Any idea on how to do this? Thx! 

  • moose said:
    Any plans to enable the input capture feature of the zephyr PWM driver?

    There's no natural way of implementing this into the driver, without depending on other drivers and external setup.

      

    moose said:
    The event can be either HItoLO, LOtoHI, or TOGGLE. The toggle event would have worked except when we route it through a PPI channel to a timer capture register; either transition will update the capture register. Any idea on how to do this? Thx!

    Connect the signal to two GPIOs, one that is configured hitolow, and the second that is configured lotohi.

     

    Kind regards,

    Håkon 

Reply
  • moose said:
    Any plans to enable the input capture feature of the zephyr PWM driver?

    There's no natural way of implementing this into the driver, without depending on other drivers and external setup.

      

    moose said:
    The event can be either HItoLO, LOtoHI, or TOGGLE. The toggle event would have worked except when we route it through a PPI channel to a timer capture register; either transition will update the capture register. Any idea on how to do this? Thx!

    Connect the signal to two GPIOs, one that is configured hitolow, and the second that is configured lotohi.

     

    Kind regards,

    Håkon 

Children
No Data
Related