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

app_pwm_channel_duty_set() in nrf_drv_timer_event_handler

Hello,

The pwm example shows changing the duty cycle inside the main while loop with delay wait.

I would like to get rid of this delay wait by putting the app_pwm_channel_duty_set() in the event_handler of a timer.

Is it possible?  What kind of priority I need to set for pwm and timer?

Thanks.

Parents
  • Hello,

     

    I assume that you are using the pwm_library example? At least in SDK15, this is the only example using the function app_pwm_channel_duty_set();

    This example uses a timer, TIMER1, as the PWM clock, and uses PPI to toggle the pins. This means that the CPU doesn't need to be interrupted to toggle the pins. You only need the application to change the duty cycle of the PWM signal using the app_pwm_channel_duty_set().

    So to answer your question:

    Yes, this is possible. you can use a timer with a callback to change the duty cycle. You can set the IRQ priority for this timer as low as possible (7). You can see the different interrupt priorities for the nRF52832 here.

     

    As mentioned, the PWM does not need any application interrupts, so it doesn't have an interrupt priority.

     

    Best regards,

    Edvin

Reply
  • Hello,

     

    I assume that you are using the pwm_library example? At least in SDK15, this is the only example using the function app_pwm_channel_duty_set();

    This example uses a timer, TIMER1, as the PWM clock, and uses PPI to toggle the pins. This means that the CPU doesn't need to be interrupted to toggle the pins. You only need the application to change the duty cycle of the PWM signal using the app_pwm_channel_duty_set().

    So to answer your question:

    Yes, this is possible. you can use a timer with a callback to change the duty cycle. You can set the IRQ priority for this timer as low as possible (7). You can see the different interrupt priorities for the nRF52832 here.

     

    As mentioned, the PWM does not need any application interrupts, so it doesn't have an interrupt priority.

     

    Best regards,

    Edvin

Children
Related