How to change pwm period on runtime in ncs?

Hi, 

I'm trying to play some sounds on a piezo with the help of the pwm. I tried to set the period with pwm_set_dt but only the first call is successful and every subsequent call raised an error. 

Here is my test code:

Fullscreen
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The results looked like this:

Fullscreen
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I didn't find anything in the documentation of pwm_set for the error 22.

How can I change period and pulse while the pwm is running?

Best regards,

Christian