nrfx_pwm_t pwm_instance = NRFX_PWM_INSTANCE(0); nrfx_err_t err_code; nrfx_pwm_config_t const config0 = { // Use "GROUPED" load mode to generate two different outputs. // Channels 0 and 1 are common and 2 and 3 are common .output_pins = { NRF_GPIO_PIN_MAP(0,5) | NRFX_PWM_PIN_INVERTED, // channel 0 NRFX_PWM_PIN_NOT_USED, // channel 1 NRFX_PWM_PIN_INVERTED, // channel 2 NRFX_PWM_PIN_NOT_USED, // channel 3 }, .irq_priority = APP_IRQ_PRIORITY_LOWEST, .base_clock = NRF_PWM_CLK_16MHz, .count_mode = NRF_PWM_MODE_UP, .top_value = 46, .load_mode = NRF_PWM_LOAD_GROUPED, .step_mode = NRF_PWM_STEP_AUTO }; err_code = nrfx_pwm_init(&pwm_instance, &config0, NULL); APP_ERROR_CHECK(err_code); // This array cannot be allocated on stack (hence "static") and it must // be in RAM (hence no "const", though its content is not changed). // This sequence is only one period. The period is then repeated in the // param to nrfx_pwm_simple_playback below static nrf_pwm_values_grouped_t /*const*/ seq_values[2]; seq_values[0] = { .group_0 = 40, .group_1 = 0 }; seq_values[1] = { .group_0 = 0, .group_1 = 40 }; nrf_pwm_sequence_t const seq = { .values.p_grouped = seq_values, .length = NRF_PWM_VALUES_LENGTH(seq_values), .repeats = 0U, .end_delay = 0U }; nrfx_pwm_simple_playback(&pwm_instance, &seq, 61, NRFX_PWM_FLAG_LOOP);