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

Cannnot toggle on/off the PWM

Hi, 

I try to Toggle ON/OFF the PWM using simple code below.

The PWM does not generate any output.

Please see code below;

/***************************************************************/
log_init();
timers_init();
leds_init();
power_management_init();
ble_stack_init();
advertising_init();


ready_flag = false;

app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(8L, NRF_GPIO_PIN_MAP(1,0) , NRF_GPIO_PIN_MAP(1,3));
err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
APP_ERROR_CHECK(err_code);

while (app_pwm_channel_duty_set(&PWM1, 0, 50) == NRF_ERROR_BUSY);
while (app_pwm_channel_duty_set(&PWM1, 1,60) == NRF_ERROR_BUSY);

// Start execution.
NRF_LOG_INFO("Beacon example started.");
advertising_start();

// Enter main loop.
for (;; )
{
app_pwm_disable(&PWM1);
nrf_delay_ms(100);
app_pwm_enable(&PWM1);
nrf_delay_ms(100);
}

/***************************************************************/

Please advise

P/S: The code have no problem to genarate PWM waveform without toggling the PWM on/Off.

Related