Allocating the SAADC to multiple DPPI channels

Hi,

I would like to enable the SAADC to read multiple DPPI channels. I am using a timer to publish multiple channels and my code looks like this:

	NRF_TIMER1->PUBLISH_COMPARE[0] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_0;
	NRF_SAADC->SUBSCRIBE_SAMPLE = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_0;

	NRF_TIMER1->PUBLISH_COMPARE[1] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_1;
	NRF_GPIOTE->SUBSCRIBE_SET[1] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_1;
	NRF_SAADC->SUBSCRIBE_SAMPLE = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_1;

	NRF_TIMER1->PUBLISH_COMPARE[2] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_2;
	NRF_GPIOTE->SUBSCRIBE_CLR[1] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_2;
	NRF_SAADC->SUBSCRIBE_SAMPLE = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_2;
	
	NRF_TIMER1->PUBLISH_COMPARE[3] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_3;
	NRF_GPIOTE->SUBSCRIBE_SET[2] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_3;
	NRF_SAADC->SUBSCRIBE_SAMPLE = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_3;

	NRF_TIMER1->PUBLISH_COMPARE[4] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_4;
	NRF_GPIOTE->SUBSCRIBE_CLR[2] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_4;
	NRF_SAADC->SUBSCRIBE_SAMPLE = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_4;

	NRF_TIMER1->PUBLISH_COMPARE[5] = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_5;

However, the SAADC is only triggered at the last SAADC subscription call: NRF_SAADC->SUBSCRIBE_SAMPLE = DPPIC_SUBSCRIBE_CHG_EN_EN_Msk | dppi_channel_4. 

Is there any way that I can trigger multiple SAADC reads within the DPPI channels?

The timer1 is initialized with the following:

static void timer1_init(void)
{
	nrfx_err_t err = NRFX_SUCCESS;
	nrfx_timer_config_t timer_cfg = NRFX_TIMER_DEFAULT_CONFIG;
	timer_cfg.bit_width = NRF_TIMER_BIT_WIDTH_32;

	err = nrfx_timer_init(&timer1, &timer_cfg, timer1_evt_handler);
	if(err != NRFX_SUCCESS)
	{
		LOG_ERR("Error! Could not initialize TIMER1: %d\n", err);
	}

	nrfx_timer_extended_compare(&timer1, NRF_TIMER_CC_CHANNEL0, nrfx_timer_us_to_ticks(&timer1, 800), NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
	nrfx_timer_extended_compare(&timer1, NRF_TIMER_CC_CHANNEL1, nrfx_timer_us_to_ticks(&timer1, 100), NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
	nrfx_timer_extended_compare(&timer1, NRF_TIMER_CC_CHANNEL2, nrfx_timer_us_to_ticks(&timer1, 200), NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
	nrfx_timer_extended_compare(&timer1, NRF_TIMER_CC_CHANNEL3, nrfx_timer_us_to_ticks(&timer1, 300), NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
	nrfx_timer_extended_compare(&timer1, NRF_TIMER_CC_CHANNEL4, nrfx_timer_us_to_ticks(&timer1, 400), NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
	nrfx_timer_extended_compare(&timer1, NRF_TIMER_CC_CHANNEL5, nrfx_timer_us_to_ticks(&timer1, 1000), NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
}

Thanks!

Ted

Parents Reply
  • Yes, so if you want SUBSCRIBE_SAMPLE to be triggered by channel 0-3, you instead trigger SUBSCRIBE_TRIGGER[0-3] in the EGU, one on each channel.
    The EGU will then publish PUBLISH_TRIGGERED[0-3], which can all be set to channel 4.
    Now, if you trigger SUBSCRIBE_SAMPLE on channel 4, you should get your desired behavior.

    We don't have many samples which use the EGU, unfortunately.

    nrf/samples/tfm/tfm_secure_peripheral
    nrf/samples/bluetooth/radio_coex_3wire

    use the EGU, but not in the same way that you are going to it seems.

Children
No Data
Related