ADC configuration for nRF5340DK SDK Connect SES

I need twoADC channels. I tried to configure using :

CONFIG_ADC= y in prj file,

&adc{
#io-channel-cells = < 0x2 >;
};   in overlay file .. the compile error appears as shown in atteched iamge.

Gulzar Singh

Parents
  • Hi,  I tried to use ADC code for single channel AIN0 from the following link.

    y0b

    The code is in attached files (adc.h, adc.c). The device binding fails as shown in attached image. adc.h

    // ADC.C File
    //****************
    static int adc_sample(void)
    {
    	int ret;
    
    	const struct adc_sequence sequence = {
    		.channels = BIT(ADC_1ST_CHANNEL_ID),
    		.buffer = p_sample_buffer,
    		.buffer_size = sizeof(p_sample_buffer),
    		.resolution = ADC_RESOLUTION,
    	};
    
    	if (!adc_dev) {
    		return -1;
    	}
    
    	ret = adc_read(adc_dev, &sequence);
    	if (ret) {
            printk("adc_read() failed with code %d\n", ret);
    	}
    
    	for (int i = 0; i < BUFFER_SIZE; i++) {
                    printk("ADC raw value: %d\n", p_sample_buffer[i]);                
            }
    	return ret;
    }
    //****************

Reply
  • Hi,  I tried to use ADC code for single channel AIN0 from the following link.

    y0b

    The code is in attached files (adc.h, adc.c). The device binding fails as shown in attached image. adc.h

    // ADC.C File
    //****************
    static int adc_sample(void)
    {
    	int ret;
    
    	const struct adc_sequence sequence = {
    		.channels = BIT(ADC_1ST_CHANNEL_ID),
    		.buffer = p_sample_buffer,
    		.buffer_size = sizeof(p_sample_buffer),
    		.resolution = ADC_RESOLUTION,
    	};
    
    	if (!adc_dev) {
    		return -1;
    	}
    
    	ret = adc_read(adc_dev, &sequence);
    	if (ret) {
            printk("adc_read() failed with code %d\n", ret);
    	}
    
    	for (int i = 0; i < BUFFER_SIZE; i++) {
                    printk("ADC raw value: %d\n", p_sample_buffer[i]);                
            }
    	return ret;
    }
    //****************

Children
No Data
Related