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

How to operate PWM and softdevice at the same time?

I`m trying to operate PWM and soft device at the same time. I have to make 4 Mhz using PWM block so I checked the PWM driver. There is no problem when using peripheral/pwmdriver.

However,when I applied pwm driver to ble_app_uart example, pwm driver code caused reboot. I can`t use app_timer because of clock frequency. How to overcome this problem?

Here is my pwm function.

WM

void EnableClock(void)
{
    uint32_t                   err_code;
    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            SEOS_CLOCK_PIN | NRF_DRV_PWM_PIN_INVERTED, // channel 0 ->   BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED,
        },
        .irq_priority = APP_IRQ_PRIORITY_LOW,
        .base_clock   = NRF_PWM_CLK_16MHz,
        .count_mode   = NRF_PWM_MODE_UP_AND_DOWN,
        .top_value    = 2,
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_TRIGGERED
    };
    err_code = nrf_drv_pwm_init(&m_pwm0, &config0, NULL);
    APP_ERROR_CHECK(err_code);
    m_used |= USED_PWM(0);

    static nrf_pwm_values_individual_t  /*const*/ seq_values[1] =
    {
        { 1 },
    };
    
    nrf_pwm_sequence_t const seq =
    {
        .values.p_individual = seq_values,
        .length              = NRF_PWM_VALUES_LENGTH(seq_values),
        .repeats             = 0,
        .end_delay           = 0
    };
    nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
}
Related