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

nRF52832 PWM doesn't start

Dear friends,

I am trying to run the PWM in my project. I have:

  • added the PWM driver successfully (4.0.0-2.alpha, nrf_drv_pwm.c, nrf_drv_pwm.h) ;

  • set #define PWM0_ENABLED 1 into nrf_drv_config.h

  • enabled PWM into sdk_config.h;

  • PWM initialization routine is like this:

/* --------------------------------------------------------------------*/

static nrf_drv_pwm_t m_pwm0 = NRF_DRV_PWM_INSTANCE(0);

void init_pwm(void) { uint32_t err_code;

nrf_drv_pwm_config_t const config0 =
{
    .output_pins =
    {
        5|NRF_DRV_PWM_PIN_INVERTED, // channel 0
        NRF_DRV_PWM_PIN_NOT_USED,             // channel 1
        NRF_DRV_PWM_PIN_NOT_USED,             // channel 2
        NRF_DRV_PWM_PIN_NOT_USED,             // channel 3
    },
    .irq_priority = APP_IRQ_PRIORITY_LOW,
    .base_clock   = NRF_PWM_CLK_125kHz,
    .count_mode   = NRF_PWM_MODE_UP,
    .top_value    = 7812,
    .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
    .step_mode    = NRF_PWM_STEP_AUTO
};
// Init PWM without error handler
err_code=nrf_drv_pwm_init(&m_pwm0, &config0, NULL);

}

/--------------------------------------------------------------------------/

  • nrf_drv_pwm_init returns NRF_SUCCESS

After all this effort the PWM obviously doesn't start; add/remove NRF_DRV_PWM_PIN_INVERTED has influence over the state of the output pin, but things stop there. I would be grateful for any advice how to solve/investigate the problem.

Related