5 Replies Latest reply on Jun 1, 2017 8:33 PM by user_342122993

    ADC+DMA Buffer problem

    ferhatyol_2020106

      Hi

         

      I am trying to do an application that takes a certain number of samples using ADC and DMA. I did an experiment by looking at the application in AN61102. DMA Transfer Done interrupt not working.

         

      This is my main.c file

         
          

      /* ========================================
       *
       * Copyright YOUR COMPANY, THE YEAR
       * All Rights Reserved
       * UNPUBLISHED, LICENSED SOFTWARE.
       *
       * CONFIDENTIAL AND PROPRIETARY INFORMATION
       * WHICH IS THE PROPERTY OF your company.
       *
       * ========================================
      */
      #include "project.h"
      #include <stdio.h>
      #include <stdlib.h>
      #include <math.h>

          

      #define SAMPLES                    128            

          

      uint16 ADC_sample[SAMPLES]={0};

          

      void ADC_DMA_Config(void);

          

      /*   ADC DMA Interrupt Handler   */
      CY_ISR(DMA_TC_ISR)
      {
         LED1_Write(~LED1_Read());
      }

          

      int main(void)
      {
        
          CyGlobalIntEnable; /* Enable global interrupts. */
          //this will initially start the timer

          

          LCD_Start();
          
          ADC_DMA_Config();
          
          LCD_Position(0u, 0u);
          LCD_PrintString("ADC DMA Test");
          
          for(;;)
          {
         
          }
      }

          

      void ADC_DMA_Config(void)
      {
          /* DMA Configuration for DMA */
          #define DMA_BYTES_PER_BURST 2
          #define DMA_REQUEST_PER_BURST 1
          #define DMA_SRC_BASE (CYDEV_PERIPH_BASE)
          #define DMA_DST_BASE (CYDEV_SRAM_BASE)  
          
          uint8 DMA_Chan;
          uint8 DMA_TD[1];
          
          DMA_TC_ISR_StartEx(DMA_TC_ISR);
          
          /* DMA Initialization - 2 byte per trigger. Each burst transfer
           * needs a new request. Set upper source and destination address. */    
          DMA_Chan = DMA_1_DmaInitialize(DMA_BYTES_PER_BURST, DMA_REQUEST_PER_BURST, 
                                       HI16(DMA_SRC_BASE), HI16(DMA_DST_BASE));    
           /* Allocate TD */
          DMA_TD[0] = CyDmaTdAllocate();
          
          /* Destination address is incremented after each transaction and 
           * Term out generated after the specified no. of bytes are transferred 
           * to memory. Tranfer the specified number of samples and generate 
           * term out */
          CyDmaTdSetConfiguration(DMA_TD[0], (2 * SAMPLES), DMA_TD[0], 
                                  DMA_1__TD_TERMOUT_EN | TD_INC_DST_ADR);     
          
          /* Set source and destination address */
          CyDmaTdSetAddress(DMA_TD[0], LO16((uint32)ADC_DelSig_1_DEC_SAMP_PTR), 
                                  LO16((uint32)ADC_sample));    
          /* Set the intial TD for the channel */
          CyDmaChSetInitialTd(DMA_Chan, DMA_TD[0]);
          
          ADC_DelSig_1_Start();
          
          /* Start the ADC conversion */
          ADC_DelSig_1_StartConvert();
      }

         
         

      That's all my settings. Is there a place I made wrong?

         

      Best Regards