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

PWM Driver starting new sequence with NRF52

I am not sure how exactly the NRF52 handles a call to start a new sequence. There are 3 different scenarios (trying to start a new sequence before, right after and way after the current sequence):

  1. When the current sequence hasn't finished yet and I try to start a new sequence (e.g. nrf_drv_pwm_simple_playback() ). What I saw happening here was actually a complete stop of the PWM driver (it seems to crash it). Is that what I should expect? So the only way to interrupt a sequence and start a new one is to actually explicitly stopping the current sequence and then running a new one (which may be visible when driving LEDs)?

  2. When you get a NRF_DRV_PWM_EVT_END_SEQx event, and even though you might have a long PWM cycle or a big repeat number, if you call for a new sequence here, it will actually wait the end of the execution of the current sequence and run the new one continuously. This is what I saw happening, is that correct?

  3. When you run a sequence without LOOP so it keeps running the last PWM cycle of the sequence after it finishes and then you call a new sequence. Even though your previous sequence has already finished before, the PWM driver is still repeating the last duty cycle (in case you don't stop the module). So if I call a new sequence here, will it interrupt the current duty cycle and run the new sequence straight away (since the previous one already finished before) or it still waits for the end of the current duty cycle before starting the new one?

Thanks in advance

  • You should be able to update the sequence on the fly instead of calling the playback function again. Problem with this is that it may start in the middle of the sequence.

    You can also stop the playback and start a new playback. The PWM peripheral will finish playing the current duty cycle before it is stopped.

    It will always wait for the end of the current duty cycle (period) to avoid glitching.

Related