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
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
Hello Gulzar,
It is needed to figure out what should be placed in the devicetree to enable two channels in the SAADC. There may be something wrong with the device tree configuration. nRF5340 has only one SAADC core with 8 input channels mux. Could you please share your .dts file?
Our getting started guide seems to have a section on its own for how to add the ADC peripheral to an example project for example https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-2-ncs-v1-4-0#h185sjwm5882m1bcimiad82dnf4kcy0b
You can also check out ADC driver documentation:https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfx/drivers/adc/index.html?highlight=ad
Thanks.
Best Regards,
Kazi Afroza Sultana
Could you please share your .dts file?
Please which .dts file you asking ? Zephyr.dts or elseone ? Zephyr.dts is attached.
Hello,
SAADC supports 8 channels- One cannel per single-ended input and two channels per differential input. So, If you want two single-ended inputs- you need to create two separate channel configurations; one for AIN0 and one for AIN1 for instance. It has to be defined from the main.c file. Also if you intend to do periodic sample using PPI or collect the sample as part of interrupt handling like this example I linked before https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/reference/peripherals/adc.html?highlight=adc_channel_cfg#c.adc_channel_cfg ; you have to define this in C file.
Best Regards,
Kazi Afroza Sultana
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; } //****************
Hello,
You have not defined the channel 2 for sampling in your code. You have to do define this.
Best Regards,
Kazi Afroza Sultana