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

Interrupt on both PWM edges

Hi Im using the pwm in the NRF52 with the following function: APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm2, &config2, pwm2_handler));

in the Interrupt function "pwm2_handler" I receive an Interrupt after each full PWM cycle. Is there a possibility to receive an Interrupt as soon as the Ouput goes high (rising edge) and once again if the output goes down (falling edge)?

Thank you

Parents
  • Hi,

    The available events from the PWM peripheral is described here. As you see, there are no event on rising or falling edge. However, you should be able to achieve this using GPIOTE. The GPIOTE peripheral can be configured to trigger interrupts on rising edge, falling edge, or both (toggle). Please checkout the GPIOTE example in the SDK.

    Note that you most likely will have to use one extra pin for the GPIOTE, and physically connect this to the PWM signal. I don't think it is possible to configure GPIOTE to trigger interrupts on a pin configured as output.

    Best regards,

    Jørgen

Reply
  • Hi,

    The available events from the PWM peripheral is described here. As you see, there are no event on rising or falling edge. However, you should be able to achieve this using GPIOTE. The GPIOTE peripheral can be configured to trigger interrupts on rising edge, falling edge, or both (toggle). Please checkout the GPIOTE example in the SDK.

    Note that you most likely will have to use one extra pin for the GPIOTE, and physically connect this to the PWM signal. I don't think it is possible to configure GPIOTE to trigger interrupts on a pin configured as output.

    Best regards,

    Jørgen

Children
Related