I have noticed the PWM library in SDK v 8.1 randomly changes polarity of the PWM channels. I can't figure out what causes it to happen... seem's random, but I doubt it.
I am almost constantly changing the duty cycle with the code below:
void pwm_ready_callback1(uint32_t pwm_id) // PWM callback function { ready_flag1 = true; }
void pwm_ready_callback2(uint32_t pwm_id) // PWM callback function { ready_flag2 = true; }
void setPWMVals( uint8_t valX, uint8_t valY ) { …
ready_flag1 = false;
while (!ready_flag1) {
APP_ERROR_CHECK(app_pwm_channel_duty_set(&PWM1, 0, valX));
}
ready_flag2 = false;
while (!ready_flag2) {
APP_ERROR_CHECK(app_pwm_channel_duty_set_hires(&PWM2, 0, valY));
}
…
}
I've also tried the other way to set the duty:
while (app_pwm_channel_duty_set(&PWM1, 0, value) == NRF_ERROR_BUSY);
But same result.
I imagine it has to do with when I set the duty, but I don't know why it would change the polarity...
Any ideas?
Thanks, Tom