First I want to mention, that I know about the pwm inverted issue.
About my project:
I have a switch which will start and stop a pwm signal. And I use a softdevice, because I also start and stop the pwm signal trough BLE.
My setup is:
-nRF51DK
-SDK 8.1
-SoftDevice 8.0
I have two functions(pwm_stop and pwm_start) for controling the pwm:
void pwm_stop(void)
{
app_pwm_disable(&PWM1);
}
void pwm_start(void)
{
app_pwm_enable(&PWM1);
while (app_pwm_channel_duty_set(&PWM1, 0, duty_cycle) == NRF_ERROR_BUSY);
}
The start and stop functions work perfectly.
I know, that the first pwm after the initializiation can be inverted. So I will start the pwm in the PWMinit function:
static void PWMinit(void)
{
app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(9000L, 15);
pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;
app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
app_pwm_enable(&PWM1);
while (app_pwm_channel_duty_set(&PWM1, 0, duty_cycle) == NRF_ERROR_BUSY);
}
but in the main, I stop the pwm after all initializations:
int main(void)
{
...
// Start execution
timers_start();
err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
pwm_stop();
}
The problem is, that the pwm signal wont be stopped after the pwm_stop function. Strange is, this function is working fine, when I call it after a switch interrupt.
Here you can see, that the pwm_stop function will be called.
And here you can see, that the pwm wont stop after the pwm_stop function
Could somebody explain me, why the pwm wont stop when I call the pwm_stop function in the main. And why is it working when I change the switch? Its the same routine...
If there is an newer app_pwm library for SDK 8.0, could somebody attach it?