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

How to control the number of pulses using app_pwm library?

Hi, I would like to generate PWM waves with on/off period as low as 10usec.

  1. How to stop the PWM and restart it? I tried this but does not stop the PWM:

    void pwm_start( void ) { nrf_drv_gpiote_out_task_enable(GPIO_YELLOW_LED_PIN_WII); app_pwm_enable(&PWM1); } void pwm_stop( void ) { app_pwm_disable(&PWM1); nrf_drv_gpiote_out_task_disable(GPIO_YELLOW_LED_PIN_WII); uint32_t err_code = app_pwm_uninit(&PWM1); APP_ERROR_CHECK(err_code);
    nrf_gpio_cfg_output(GPIO_YELLOW_LED_PIN_WII); nrf_gpio_pin_set(GPIO_YELLOW_LED_PIN_WII); }

  2. How to control the number of PWM pulses? I want to output 1 PWM pulse upon button press. Thanks.

  • Also I found that there is an initial delay of ~600usec for the pwm module to get ready (when using app_pwm library). So If I need to generate just 1 pwm pulse, I cannot use this app_pwm library, isn't it? So I am reverting back to PPI+GPIOTE+Timer code to generate pwm pulses (as given in the drv version 1.2.0). But with this there is a risk of pwm pulse inversion when an interrupt is missed (when I use this library with BLE). How to handle this situation? Thanks.

Related