Hi there,
I've encountered a strange PWM behavior and have investigated a bit. When setting load_mode to NRF_PWM_LOAD_WAVE_FORM, creating two sequence, and the latter sequence length is sizeof(nrf_pwm_values_wave_form_t)/sizeof(uint16_t), the latter sequence will only be executed once no matter how much repeats is set. I'll paste my code below
#define PWM_WAVE_LEN 4 #define PWM_WAVE_LEN2 1 static nrf_pwm_values_wave_form_t pwm_wave_form_values[PWM_WAVE_LEN]; static nrf_pwm_values_wave_form_t pwm_wave_form_values2[PWM_WAVE_LEN2]; uint16_t counter_top = 100; uint16_t counter_bottom = 1600; for(int i=0; i<PWM_WAVE_LEN; i++) { pwm_wave_form_values[i].counter_top = counter_top; pwm_wave_form_values[i].channel_0 = counter_top / 2; counter_top = counter_top * 2; } for(int i=0; i<PWM_WAVE_LEN2; i++) { pwm_wave_form_values2[i].counter_top = counter_bottom; pwm_wave_form_values2[i].channel_0 = counter_bottom / 2; counter_bottom = counter_bottom / 2; } static nrf_pwm_sequence_t pwm_sequence = { .values.p_wave_form = pwm_wave_form_values, .length = (sizeof(pwm_wave_form_values) / sizeof(uint16_t)), .repeats = 4, .end_delay = 0 }; static nrf_pwm_sequence_t pwm_sequence2 = { .values.p_wave_form = pwm_wave_form_values2, .length = (sizeof(pwm_wave_form_values2) / sizeof(uint16_t)), .repeats = 4, .end_delay = 0 }; nrfx_pwm_complex_playback(&m_pwm, &pwm_sequence, &pwm_sequence2, 1, NRFX_PWM_FLAG_LOOP|NRFX_PWM_FLAG_NO_EVT_FINISHED);
If PWM_WAVE_LEN2 is 1, repeats in pwm_wave_form_values2 does not take effect. See logic analyzer results below.
If increase PWM_WAVE_LEN2 to 2, everything seems fine. See logic analyzer results below.
I need to confirm whether this is a designed feature or I made a misconfigure.