Hello,
I am trying to use PWM in the simple coap client example.
Unfortunately the PWM is not working, I do not get any signal on the output pins.
If I remove the line with thread_instance_init(); then the PWM works.
I only added the following function to the simple coap client example in nRF5_SDK_for_Thread_and_Zigbee_2.0.0_29775ac:
APP_PWM_INSTANCE(PWM1,2);
APP_PWM_INSTANCE(PWM2,3);
APP_PWM_INSTANCE(PWM3,4); // Create the instance "PWM1" using TIMER1.
void init_pwm(void)
{
ret_code_t err_code;
/* 1-channel PWM, 200Hz, output on DK LED pins. */
app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(PWM_PERIOD, LED_1);
app_pwm_config_t pwm2_cfg = APP_PWM_DEFAULT_CONFIG_1CH(PWM_PERIOD, LED_2);
app_pwm_config_t pwm3_cfg = APP_PWM_DEFAULT_CONFIG_1CH(PWM_PERIOD, LED_3);
/* Initialize and enable PWM. */
err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback);
APP_ERROR_CHECK(err_code);
err_code = app_pwm_init(&PWM2,&pwm2_cfg,pwm_ready_callback);
APP_ERROR_CHECK(err_code);
err_code = app_pwm_init(&PWM3,&pwm3_cfg,pwm_ready_callback);
APP_ERROR_CHECK(err_code);
app_pwm_enable(&PWM1);
app_pwm_enable(&PWM2);
app_pwm_enable(&PWM3);
while (app_pwm_channel_duty_set(&PWM1, 0, 50) == NRF_ERROR_BUSY);
while (app_pwm_channel_duty_set(&PWM2, 0, 50) == NRF_ERROR_BUSY);
while (app_pwm_channel_duty_set(&PWM3, 0, 50) == NRF_ERROR_BUSY);
}
and here the main:
int main(int argc, char * argv[])
{
log_init();
scheduler_init();
timer_init();
thread_instance_init();
thread_coap_init();
thread_bsp_init();
timers_start();
init_pwm();
while (true)
{
thread_process();
app_sched_execute();
if (NRF_LOG_PROCESS() == false)
{
thread_sleep();
}
}
}
I think my problem could be related to the following post:
https://devzone.nordicsemi.com/f/nordic-q-a/45816/pwm-conflict-with-freertos-thread-example
Doing I am something wrong?
Thanks in advance
Thomas