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

Should PWM end_delay be honoured or ignored if playback_count is 1 ?

I've modified the simple_pwm example from : devzone.nordicsemi.com/.../

I've either misunderstood or have found a bug where by the 'end_delay' value is ignored if the 'playback_count' prameter is set to 1 when calling 'nrf_drv_pwm_simple_playback'.

I wondered if someone could clarify this for me please?

Thanks Wayne

The code:

static void pwm_simple(void)
{
	uint32_t err_code;
	nrf_drv_pwm_config_t const config0 =
	{
			.output_pins =
			{
					BSP_LED_1 | 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_1MHz,
			.count_mode   = NRF_PWM_MODE_UP,
			.top_value    = 10,
			.load_mode    = NRF_PWM_LOAD_COMMON,
			.step_mode    = NRF_PWM_STEP_AUTO
	};

	err_code = nrf_drv_pwm_init(&m_pwm0, &config0, NULL);
	APP_ERROR_CHECK(err_code);

	static nrf_pwm_values_common_t seq_values[] =
	{
			10, 0
	};

	nrf_pwm_sequence_t const seq =
	{
			.values.p_common = seq_values,
			.length          = NRF_PWM_VALUES_LENGTH(seq_values),
			.repeats         = 0,
			.end_delay       = 5        // Has no effect unless the '1' below is >1
	};

	nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);

}
Parents
  • Hello Wayne

    You are right. When using the LOOP flag the end_delay will be ignored for the last duty cycle during the final execution of the sequence. However, the correct number of repeats are executed.

    When using the STOP flag both end_delay and repeats are ignored for the last duty cycle on the final execution of the sequence.

    It seems this isn't mentioned in the documentation. I will bring it forward.

    As a work-around to get the correct number of repeats for the final duty cycle you can reduce the number of repeats per duty cycle, and add several instances for each duty cycle.

    i.e. if you have top value 100 and sequence = {50, 20}; and you want 50 to be repeated 10 times, while 20 is repeated 15 times you can use

    sequence = {50, 50, 20, 20, 20};
    

    with

    .repeats = 4; 
    .end_delay=0;
    

    This way each duty cycle is executed 5 times each.

    Best regards

    Jørn Frøysa

  • It looks like three years passed and the documentation is still not updated. It says just about ignoring end_delay in NRF_PWM_STEP_TRIGGERED.

Reply Children
No Data
Related