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

PWM Sequence loop

Hi,

I read in the documentation that one can loop a complex playback. The way I understood, one could load a first sequence (say seq1) and a second sequence (say seq2) and then loop the whole thing. So this should happen:

seq1->seq2->seq1->seq2->seq1->seq2....

But if I set playback_count=1 I get:

seq1->seq1->seq1.....

if I set playback_count=2 I get:

seq1->seq2->seq1->seq1->seq2->seq1.....

How should I set it up to get continuous alternation between seq1 and seq2 forever?

UPDATE: it only happens like this when the seq2 has only one element. If I add a second element to it, it works as expected with playback_count=1. Is this some kind of bug?

Thanks

  • Sorry for the late reply.

    What is the value of nrf_pwm_sequence_t.repeats? This determine how many extra times the sequence should be played (a value of '1' should give seq1->seq1->seq2->seq2->seq1->seq1...).

    I get the seq1->seq1->seq1... only if I have playback_count = 0, regardless of what value repeats are. If repeats is '1' and playback_count = 1 I get seq1->seq1->seq2->seq1->seq1->seq2...

    All other values give the correct behavior.

  • Im seeing behavior that may be related. With the goal of playing a series of sequences, the product I'm working on first calls a nrf_drv_pwm_complex_playback then on the NRF_DRV_PWM_EVT_FINISHED event a nrf_drv_pwm_simple_playback is called and given a sequence with length 1. It then does this again for a different third sequence with a longer length. The result is that the sequence with length 1 is called for a very small amount of time (~75 ms). I am toggling GPIOs on NRF_DRV_PWM_EVT_FINISHED, NRF_DRV_PWM_EVT_END_SEQ0, and NRF_DRV_PWM_EVT_END_SEQ1 to indirectly debug the timing. When I change it to length 2 and reduce the repeat counts accordingly the system behaves as expected. Have you tried measuring the timing from those events?

  • I didn't properly measured but I remembed that clearly the timing was shorter than it should on seq2 when it had only one element. As if it didn't actually wait for the whole time it should but just the enough time to load the value and then reset it all....

Related