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 Reply
  • Hello,

    1. In the adc.h, if #define  BUFFER_SIZE 2  right or wrong to sample 2 analog channels ? If in future, 3 chhannels are required, may I set #define  BUFFER_SIZE 3.

    The buffer size should be set to N*number of enabled channels, as SCAN mode will sample each channel subsequently and put the result in the RAM buffer as described here: https://infocenter.nordicsemi.com/topic/ps_nrf5340/saadc.html?cp=3_0_0_6_28_4_3#saadc_operationmodes_scan. If you set a buffer size that does not match the number of enabled channels, you will miss samples, or samples will be stored in the buffer in non-deterministic order.

    2. In the main file, I adc instantiated by binding and then, set up channels using err = adc_channel_setup() .. function. Is it proper way ?

    yes it is.

    3. '' #if defined (CONFIG_BOARD_BMS_NRF5340_CPUAPP)
    NRF_SAADC->TASKS_CALIBRATEOFFSET = 1''

    this task will start offset auto-calibration in SAADC peripheral. 

    4. I wrote two sample functions, as in adc.c. Is this proper way to add to sequence ? If, wrong any where, may you make changes and attached corrected code file ?

    It is ok. I have added a sample code where 2 channels are used. you can look at this as reference. 

    5. I called adc sampling functions in repeatitive timer. Is the result of adc from AIN0 and AIN1 be avaialble at same index or at different indices in p_sample_buffer[]

    Indexes will be different if both channels are enabled at once and scan mode are used. p_sample_buffer[] will have different values.  

    Regards,

    Kazi Afroza Sultana

Children
No Data
Related