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

  • Hi Jorgen

    Thank you for the information. I think I need to use the DMA functuion like this:

    NRF_PWM[x]->EVENTS_PWMPeriod -> NRF_TIMER[y]->TASKS_START NRF_TIMER[y]->EVENTS_COMPARE[0] -> NRF_SAADC->TASKS_START NRF_TIMER[y]->EVENTS_COMPARE[1] ->NRF_SAADC->TASKS_START

    Did anybody know an example to configure the EasyDMA for this events above. Or can somebody tell me wehere is the discription to set the EasyDMA Mode correctly.

    Thanks a lot

Reply
  • Hi Jorgen

    Thank you for the information. I think I need to use the DMA functuion like this:

    NRF_PWM[x]->EVENTS_PWMPeriod -> NRF_TIMER[y]->TASKS_START NRF_TIMER[y]->EVENTS_COMPARE[0] -> NRF_SAADC->TASKS_START NRF_TIMER[y]->EVENTS_COMPARE[1] ->NRF_SAADC->TASKS_START

    Did anybody know an example to configure the EasyDMA for this events above. Or can somebody tell me wehere is the discription to set the EasyDMA Mode correctly.

    Thanks a lot

Children
No Data
Related