1 Reply Latest reply on Oct 21, 2018 9:55 PM by anks

    Getting I2S Tx and Rx working with DMA (PSOC5)

    mccartneydamon_1553781

      Hi all!

       

      I'm having some bother with the DMA and understanding a few concepts. I've spent most of the weekend on this and can not get it working so turning to the trusted sages on here.

       

      Basically I want to read in some 16bit values to , do something with them and pass them out again. So far I only have the Tx working with some sine wave test data but it would make my week if I could just pass Rx to Tx! I have the I2S block and DMA_1_ is connected to the Tx_DMA and DMA_2 to the Rx_DMA.

       

      Thanks in advanced, code below.

      #include "project.h"

       

      void DmaTxConfiguration(void);

      void DmaRxConfiguration(void);

       

      #define DMA_1_BYTES_PER_BURST 1

      #define DMA_1_REQUEST_PER_BURST 1

      #define DMA_1_SRC_BASE (CYDEV_SRAM_BASE)

      #define DMA_1_DST_BASE (CYDEV_PERIPH_BASE)

       

      /* DMA Configuration for RxDMA */

      #define DMA_2_BYTES_PER_BURST       (1)

      #define DMA_2_REQUEST_PER_BURST     (1)

      #define DMA_2_SRC_BASE              (CYDEV_PERIPH_BASE)

      #define DMA_2_DST_BASE              (CYDEV_SRAM_BASE)

       

      #define LEN 101

       

      int16_t inData[LEN];

      int16_t outData[LEN];

       

      int main(void)

      {

          CyGlobalIntEnable; /* Enable global interrupts. */

          Clock_1_Start();

          I2S_1_Start();

          I2C_1_Start();

          isr_1_Start();

         

          ADC_DelSig_1_Start();

          codecConfig();

          ADC_DelSig_1_StartConvert();

         

          DmaTxConfiguration();

          DmaRxConfiguration();

         

          I2S_1_EnableRx();

            

          while(0u != (I2S_1_ReadTxStatus() & I2S_1_TX_FIFO_0_NOT_FULL))

          {/*wait*/}

       

          I2S_1_EnableTx();   /* Enable Tx direction */

         

          for(;;);

      }

       

       

      void DmaTxConfiguration(void)

      {

          uint8 TxDMA_Chan;

          uint8 TxDMA_TD[1u];   

          TxDMA_Chan = DMA_1_DmaInitialize(DMA_1_BYTES_PER_BURST, DMA_1_REQUEST_PER_BURST, HI16(DMA_1_SRC_BASE), HI16(DMA_1_DST_BASE));

          TxDMA_TD[0u] = CyDmaTdAllocate();

           

          CyDmaTdSetConfiguration(TxDMA_TD[0u],LEN, TxDMA_TD[0u], CY_DMA_TD_INC_SRC_ADR);

          CyDmaTdSetAddress(TxDMA_TD[0u], LO16((uint32)inData), LO16((uint32)I2S_1_TX_CH0_F0_PTR));

          CyDmaChSetInitialTd(TxDMA_Chan, TxDMA_TD[0u]);

          CyDmaChEnable(TxDMA_Chan, 1u);

      }

       

      void DmaRxConfiguration(void)

      {

          uint8 RxDMA_Chan;

          uint8 RxDMA_TD[1u];   

          RxDMA_Chan = DMA_2_DmaInitialize(DMA_2_BYTES_PER_BURST, DMA_2_REQUEST_PER_BURST, HI16(DMA_2_SRC_BASE), HI16(DMA_2_DST_BASE));

          RxDMA_TD[0u] = CyDmaTdAllocate();

           

          CyDmaTdSetConfiguration(RxDMA_TD[0u],LEN, RxDMA_TD[0u], CY_DMA_TD_INC_DST_ADR);

          CyDmaTdSetAddress(RxDMA_TD[0u], LO16((uint32)I2S_1_RX_CH0_F0_PTR), LO16((uint32)outData));

          CyDmaChSetInitialTd(RxDMA_Chan, RxDMA_TD[0u]);

          CyDmaChEnable(RxDMA_Chan, 1u);

      }