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

PWM on 3 pins

I have a nrf51 dongle and would like to use PWM on 3 pins. Managed to get it working on pins 15 and 16, but somehow pins from 17 to 20 just don't work. For example: I set an LED on pin 17 and when using PWM it turns on and immediately off.

To use PWM on three pins I resorted to using 2 timers (TIMER1 and TIMER2) and the code is like that:

app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(5000L, 15, 16);
err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
APP_ERROR_CHECK(err_code);
app_pwm_enable(&PWM1);
ready_flag = false;
while (app_pwm_channel_duty_set(&PWM1, 0, 0) == NRF_ERROR_BUSY);
while(!ready_flag);
APP_ERROR_CHECK(app_pwm_channel_duty_set(&PWM1, 1, 0));

app_pwm_config_t pwm3_cfg = APP_PWM_DEFAULT_CONFIG_1CH(5000L, 17);    
err_code = app_pwm_init(&PWM1,&pwm3_cfg,pwm_ready_callback3);
APP_ERROR_CHECK(err_code);
app_pwm_enable(&PWM2);
ready_flag3 = false;
while (app_pwm_channel_duty_set(&PWM2, 0, 50) == NRF_ERROR_BUSY);

If I try setting the pin 17 with command nrf_gpio_set(17) LED turns on without a problem. I have even tried using only 1st part of the code (just 2 channels), but if I use any pin from 17 on the PWM doesn't work.

BTW - I'm using SDK11.

Any ideas, what I might check?

Parents Reply Children
Related