AnsweredAssumed Answered

MKL16 ADC read using DMA

Question asked by Balkrishna Amrutrao on May 13, 2019
Latest reply on May 21, 2019 by Balkrishna Amrutrao

Came across code for MKL16 controller, where ADC single channel data is read in DMA interrupt in "uint32 adc_data[4]". And after reading data using DMA_PrepareTransfer(), data in adc_data[1] is used while ignoring adc_data[0]. Code seems to work fine, what can be the justification for this? ADC is configured for differential conversion and auto calibration is enabled.


ADC configuration: resolution = 16 bit

longSampleMode = kADC16_LongSampleCycle24

enableContinuousConversion = false

enableInterruptOnConversionCompleted = false

enable dma = true 

sample code :


uint32 adc_data[4];

//interrupt used for reading ADC data



int data;


DMA_PrepareTransfer(&DMA_TransferConfig, (void *)(uint32_t)(&ADC0->R[0]), sizeof(uint32_t),
(void *)adc_data, sizeof(uint32_t), sizeof(adc_data),

data = adc_data[1];// why adc_data[0] is ignored?

AveragedReading = averaged_value_of_'data';