Michael Nehls

Transferring ADC result via eDMA (KSDK 2.0)

Discussion created by Michael Nehls on Apr 6, 2017
Latest reply on Apr 7, 2017 by Michael Nehls

I'm pretty new to all this. Just started developing for Kinetis with KSDK 2.0 and have some problems. I think I don't understand every detail completely.

I want to start one ADC conversion with software trigger. After finished conversion the result should be copied to SRAM. I used the examples for MemoryToMemory copy and the interrupt example for ADC.

Both alone work fine, but when I want to combine this the callback is never fired. I think the problem might be my ADC initialisation.


#define ADC_BASEADDR                         (ADC1)
#define ADC_CHANNEL_GROUP               (0U)
#define ADC_USER_CHANNEL               (18U)
#define ADC_DR                                   (ADC_BASEADDR->R[ADC_CHANNEL_GROUP])

#define DMA_BASEADDR                         (DMA0)
#define DMA_CHANNEL                         (3)

#define BUFFER_SIZE                         (8)
static void initADC(void) {
     adc16_config_t adc16ConfigStruct;

     ADC16_Init(ADC_BASEADDR, &adc16ConfigStruct);
     ADC16_EnableHardwareTrigger(ADC_BASEADDR, true);
     ADC16_EnableDMA(ADC_BASEADDR, true);

     g_adc16ChannelConfigStruct.channelNumber = ADC_USER_CHANNEL;
     g_adc16ChannelConfigStruct.enableInterruptOnConversionCompleted = false;
static void initDMA(void) {
     memset(adc_mem, 0x55, sizeof(adc_mem));

     /* Configure DMAMUX */
     DMAMUX_EnableChannel(DMAMUX0, DMA_CHANNEL);

     edma_config_t edma_config;
    edma_transfer_config_t transfer_config;

     /* Init the eDMA driver */
     EDMA_Init(DMA_BASEADDR, &edma_config);
     EDMA_CreateHandle(&edma_handle, DMA_BASEADDR, DMA_CHANNEL);
     EDMA_SetCallback(&edma_handle, dmaCallback, NULL);
     EDMA_PrepareTransfer(&transfer_config, &ADC_DR, 2, adc_mem, 2, 1, 1, kEDMA_PeripheralToMemory);
   if (EDMA_SubmitTransfer(&edma_handle, &transfer_config) == kStatus_Success) {
          PRINTF("\r\nEDMA Submit Transfer: Success\r\n");
     } else {
          PRINTF("\r\nEDMA Submit Transfer: Failed\r\n");

int main(void) {
     uint8_t msg = ' ';


     PRINTF("\r\nPress any key to start demo.\r\n");
    PRINTF("\r\nInitializing ADC\r\n");
     PRINTF("\r\nInitializing DMA\r\n");

     while (1) {
          PRINTF("Destination Buffer:\r\n");
          int i = 0;
          for (i = 0; i < BUFFER_SIZE; i++) {
               PRINTF("%d\t", adc_mem[i]);

          ADC16_SetChannelConfig(ADC_BASEADDR, ADC_CHANNEL_GROUP, &g_adc16ChannelConfigStruct);
          while (dmadone != true)
          PRINTF("\r\nDMA DONE\r\n");