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

Outputting a PWM signal at 8Mhz with 50% dutcy cycle

We are working with SDK 12.1 and are noticing the max value we can output using the PWM driver is about 5.3Mhz (top value to 3 and 16Mhz for the clock) this isn't a 50% duty cycle either. This is confirmed in the data sheet as by looking at the COUNTERTOP.

Using the code below

static void start_pwm(void)
{
    uint32_t err_code;
    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            IND_PWM_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_HIGH,
        .base_clock   = NRF_PWM_CLK_8MHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = 2,
        .load_mode    = NRF_PWM_LOAD_COMMON,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    err_code = nrf_drv_pwm_init(&m_pwm, &config0, NULL);
    APP_ERROR_CHECK(err_code);

    static uint16_t seq_values[] ={1};

    nrf_pwm_sequence_t const seq =
    {
        .values.p_common = seq_values,
        .length          = NRF_PWM_VALUES_LENGTH(seq_values),
        .repeats         = 0,
        .end_delay       = 0
    };

    nrf_drv_pwm_simple_playback(&m_pwm, &seq, 0,  NRF_DRV_PWM_FLAG_LOOP);
}

I am able to generate a PWM output of 4Mhz with a 50% duty cycle.If we change the base clock to 16Mhz we don't see a signal.

Is is possible to achieve an 8Mhz output with 50% duty cycle? If so, what do we have to change with the above code?

Related