nRFX PWM task register address mismatch between nrfx_pwm_simple_playback and nrfx_pwm_task_address_get

I've got an NCS v2.6.1 project on the nRF52832 running a timing chain using PPI for PWM instance 2:

#define STIM_PWM 2
nrfx_pwm_t pwm_instance = NRFX_PWM_INSTANCE(STIM_PWM);

...

uint32_t task_addr = nrfx_pwm_simple_playback(&pwm_instance, &biphasic_seq, 1, NRFX_PWM_FLAG_START_VIA_TASK);
uint32_t exp_addr = nrfx_pwm_task_address_get(&pwm_instance, NRF_PWM_TASK_SEQSTART0);
if (task_addr != exp_addr)
{
    LOG_ERR("Start trigger address unexpected (0x%x != 0x%x)", task_addr, exp_addr);
    fault_config();
}

The output of nrfx_pwm_task_address_get is 0x40022008 as I'd expect from the PWM peripheral registers table for PWM2

However, nrfx_pwm_simple_playback returns 0x40018008, which doesn't seem to match up to any of the addresses in the PWM table. Instead, I found that it seems to be in the address space of the SWI peripheral.

I'm currently using the return from nrfx_pwm_task_address_get in my PPI configuration. Is there a reason to use one or the other with nrfx_gppi_channel_endpoints_setup?

Parents Reply Children
  • it looks like in nrfx_pwm.c->start_playback-> you have this code

        if (flags & NRFX_PWM_FLAG_START_VIA_TASK)
        {
            uint32_t starting_task_address =
                nrfy_pwm_task_address_get(p_instance->p_reg, nrfy_pwm_seqstart_task_get(seq_id));
    
    #if defined(USE_DMA_ISSUE_WORKAROUND)
            // To "protect" the initial DMA transfer it is required to start
            // the PWM by triggering the proper task from EGU interrupt handler,
            // it is not safe to do it directly via PPI.
            p_cb->starting_task_address = starting_task_address;
            nrf_egu_int_enable(DMA_ISSUE_EGU, nrf_egu_channel_int_get(p_instance->instance_id));
            return nrf_egu_task_address_get(DMA_ISSUE_EGU,
                                            nrf_egu_trigger_task_get(p_instance->instance_id));
    #else
            return starting_task_address;
    #endif
        }

    So it looks like when NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED is enabled with CONFIG_NRF52_ANOMALY_109_WORKAROUND then we have USE_DMA_ISSUE_WORKAROUND makes the workaround via EGU instead of PPI, so that could be the reason to see different task address. 

Related