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

PWM not pulsing

I have a custom board SDK 15.2 API 6.1

I have a simple PWM going but it seems to just turn the low and set it high when i turn it on. It does not however seem to pulse according to my scope. Nor does it stop. This is in a ble application that has softdevices enabled and LFCLK source. I am tyring to use app_pwm.h instead of the nrf_drv_pwm. I am curious why a simple application doe snot seem to operate though.

static nrf_drv_pwm_t m_pwm0 = NRF_DRV_PWM_INSTANCE(0);

nrf_pwm_values_individual_t seq_values[] = {DUTY_CYCLE, 0, 0, 0};
nrf_pwm_sequence_t const seq =
{
    .values.p_individual = seq_values,
    .length          = NRF_PWM_VALUES_LENGTH(seq_values),
    .repeats         = 0,
    .end_delay       = 0
};


void pwm_start(void)
{
    nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
}

void pwm_stop(void)
{
    nrf_drv_pwm_stop(&m_pwm0, false);
}

static void pwm_init(void)
{
    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            OUTPUT_PIN, // 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_LOWEST,
        .base_clock   = NRF_PWM_CLK_1MHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = 100,
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    // Init PWM without error handler
    APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config0, NULL));
    
}

void int main(void){
    pwm_init();
    pwm_start();
    nrf_delay_ms(2000);
    pwm_stop();
}

Parents Reply Children
No Data
Related