Hello,
I'm working on nRF52811, SDK16.0, Softdevice 7.0.1.
Using the pwm_driver example in the SDK, I'm trying to run a simple PWM for an RGB LED. Following is my simplified code. I can see the PWM at output but changing duty cycle (by seq_values->channel_0 = value; ) does not effect the output (no color change). I have tried the demo app on an nRF52840 board and that works fine. But I have to do it on my custom made nRF52811 board. Please help.
#include <stdio.h> #include <string.h> #include "nrf_drv_pwm.h" #include "app_util_platform.h" #include "app_error.h" #include "boards.h" //#include "bsp.h" #include "nrf_drv_clock.h" #include "nrf_delay.h" #include "nrf_log.h" #define OUTPUT_PIN_1 30 #define OUTPUT_PIN_2 28 #define OUTPUT_PIN_3 25 static nrf_drv_pwm_t m_pwm0 = NRF_DRV_PWM_INSTANCE(0); // Declare variables holding PWM sequence values. In this example only one channel is used nrf_pwm_values_individual_t seq_values[] = {0, 0, 0, 0}; nrf_pwm_sequence_t const seq = { .values.p_individual = seq_values, .length = NRF_PWM_VALUES_LENGTH(seq_values), .repeats = 0, .end_delay = 0 }; static void pwm_init(void) { nrf_drv_pwm_config_t const config0 = { .output_pins = { OUTPUT_PIN_1, // channel 0 OUTPUT_PIN_2, // channel 1 OUTPUT_PIN_3, // channel 2 NRF_DRV_PWM_PIN_NOT_USED, // channel 3 }, .irq_priority = APP_IRQ_PRIORITY_LOWEST, .base_clock = NRF_PWM_CLK_1MHz, .count_mode = NRF_PWM_MODE_UP, .top_value = 100, .load_mode = NRF_PWM_LOAD_INDIVIDUAL, .step_mode = NRF_PWM_STEP_AUTO }; // Init PWM without error handler APP_ERROR_CHECK(nrf_drv_pwm_init(&m_pwm0, &config0, NULL)); } void rgb_outputs_init(void) { // // Start clock for accurate frequencies // NRF_CLOCK->TASKS_HFCLKSTART = 1; // // Wait for clock to start // while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0); pwm_init(); seq_values->channel_0 = 0; seq_values->channel_1 = 50; seq_values->channel_2 = 0; nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP); NRF_LOG_INFO("PWM Initialized..."); }