3 Replies Latest reply on May 12, 2015 3:39 PM by JoMe_264151

    DMA fails to capture results from an ADC?

      I have a DMA setup to capture 4095 8-bit samples from an ADC and then send it via UART to my PC. All of this is done in one procedure :

       void pulseAndReg() { // uint16 PulseSampleNo = SAMPLES_IN_BUFFER; ADC_Mag_StartConvert(); pulseEndFlag = 0;
          // transmit the pulse    
          // start collecting data
          CyDmaChEnable(DMA_1_Chan, 1);
          // wait for end of collection
              //block until collection finished
          UART_PC_PutArray(samplesBuffer8, SAMPLES_IN_BUFFER);


      Before the procedure runs a bunch of stuff is being initialized before main():


      #define SAMPLES_IN_BUFFER (uint16)(0x0FFF)
      #define PULSE_LENGTH_US 300u

      /* Variable declarations for DMA_1 */
      /* Move these variable declarations to the top of the function */
      uint8 DMA_1_Chan;
      uint8 DMA_1_TD[1];

          /* DMA Configuration for DMA_1 */
      #define DMA_1_BYTES_PER_BURST 1
      #define DMA_1_REQUEST_PER_BURST 1
      #define DMA_1_DST_BASE (CYDEV_SRAM_BASE)


      uint8 samplesBuffer8[SAMPLES_IN_BUFFER] = {0};


      and in main():


          DMA_1_Chan = DMA_1_DmaInitialize(DMA_1_BYTES_PER_BURST, DMA_1_REQUEST_PER_BURST,
         HI16(DMA_1_SRC_BASE), HI16(DMA_1_DST_BASE));
          DMA_1_TD[0] = CyDmaTdAllocate();
          CyDmaTdSetConfiguration(DMA_1_TD[0], SAMPLES_IN_BUFFER, DMA_1_TD[0], DMA_1__TD_TERMOUT_EN | TD_INC_DST_ADR);
          CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)ADC_Mag_DEC_SAMP_PTR), LO16((uint32)samplesBuffer8));
          CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);


          CyGlobalIntEnable;  /* Uncomment this line to enable global interrupts. */




      My problem is, all that seems to be inhabitting the samplesBuffer8 after the procedure is run is a bunch of ones, nothing else. I've been trying to debug this problem for ages now and I can't seem to figure out the reason why the program behaves this way. Any ideas anyone?