Hello,
I am running an application on the s140 soft device using the buttonless dfu as an example. I am using the dual ramp pwm scheme to generate complementary pwm waveforms for a DC-DC converter. This works great for me but I am running into an issue that is perplexing me.
Background:
I have successfully been able to implement an initialization function using nrfx_pwm_init. I then use nrfx_pwm_simple_playback to start my pwm as follows which I got from a dual ramp example I found.
PWM_LoopTable[0].channel_0 = 0x8000 | PwmHiaDutyCycle;
PWM_LoopTable[0].channel_1 = PwmLiaDutyCycle;
(void)nrfx_pwm_simple_playback(&myPWM, &seq0, 1,NRFX_PWM_FLAG_LOOP);
The Pwm starts up with no issues.
When I want to stop the PWM but not completely deinitialize it, I call nrfx_pwm_stop as follows
nrfx_pwm_stop(&myPWM, 1);
I understand that the 1 I am passing indicates to the function that it should wait until the pwm is stopped before exiting the function.
Typically, this function works great. I use it very often to regulate voltage. i.e. when the voltage exceeds a certain value I call this function and when it returns back below a threshold I call the nrfx_pwm_simple_playback again and the pwm starts back up.
Occasionally, and with no discernable pattern that I can find, the stop function will not actually stop the pwm. I will call the function, and as I said before it is waiting until nrfx_pwm_is_stopped returns true before exiting. However, The pwm remains on. I have another check in my code every second that is polling nrfx_pwm_is_stopped and this is returning true to me even though the pwm itself is still on.
I have no idea how this is the case. For now, I am planning on putting a timer based check into my code that will be able to find tis error state and call a full deinitialization of the pwm in an attempt to stop it. However, this feels like a brute force way to do this. Is there some other check function I can use that will determine if pwm is occurring that is deeper than nrfx_pwm_is_stopped() ?? Is there some other way that would ensure the pwm is off when I call nrfx_pwm_stop?
Any ideas or assistance on this would be much appreciated.
Austin