This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

configuring multiple saadc channels

Hi,

I want to configure 2 channels of saadc in differential mode as follows:

void saadc_init(void) //ok
{
    ret_code_t err_code;

	nrf_saadc_channel_config_t channel_config1 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN4,NRF_SAADC_INPUT_AIN6);
	nrf_saadc_channel_config_t channel_config2 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_DIFFERENTIAL(NRF_SAADC_INPUT_AIN5,NRF_SAADC_INPUT_AIN7);

    err_code = nrf_drv_saadc_init(NULL, saadc_callback);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_channel_init(0, &channel_config1);
    APP_ERROR_CHECK(err_code);
		err_code = nrf_drv_saadc_channel_init(1, &channel_config2);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
		
		nrf_saadc_continuous_mode_enable(800);
	

}

But when I received data, it seems that only the channel that its channel index is zero is enabled. may you help me to find the issue and configure this 2 channel in scan mode? i am working based on the saadc example in sk17. 

  • Masoumeh said:
    Can we configure multiple differential channels with a common ANI?

    Since the SAADC input muxes needs to be reconfigured between each channel anyway, I do not see any technical reasons that this should not work.

    Masoumeh said:
    I want to measure the input noise of my analog system, so I shorted the input signals. I saw that the second channel of ADC data is some how incorrect and quantized.

    Are the samples somehow processed before plotted in the graphs? What does the raw SAADC samples look like?

    Have you tested with a slower sample rate, to make sure that the previous sampling is completed on both channels before starting the next? By default, the acquisition time per channel should be 10us, so unless you have not modified the drivers, you should have plenty of time for 2 channels in 50 us.

  • Yes, I convert them to voltage but the program is ok, I tested it. I reduce the SR but the problem is still there. Also my acquisition time is 10us. the interesting thing is that, when I imply an sin input to the second channel, its function is ok and I will have the correct answer. 

    Another problem I have is that I have some kind of noise on my signal which includes some harmonic in 2k,4k,6k,..... I think it comes from the power switching between LDO and DCDC. Do you know how often do MCU switch between them? or what is the frequency of this task? 

  • The switching between LDO and DCDC is handled automatically by the chip depending on the load: "Automatic switching between LDO and DC/DC regulator based on load to maximize efficiency"

    The DCDC switching itself happens at 8MHz, as mentioned in this post. It is possible that it could be harmonics to this, but I would need to verify that with our developers. Have you verified that the harmonics disappear if you do not enable the DCDC regulator?

  • I want to send data in 98 bytes length (payload length =98), but the nrf_esb_create_payload shows errors when I put more than 64 bytes in it. what is the problem?

  • As mentioned in API documentation for NRF_ESB_CREATE_PAYLOAD, it can only support 1 to 63 values. This may be a limitation of supported elements in __VA_ARGS__ list used in the macro. You can set the parameters in the struct yourself according to the code shown in the API documentation if you need longer payloads.

Related