3 Replies Latest reply on Jun 18, 2019 11:53 PM by alli_264371

    How to set DMA to transfer 36 bytes from a char DATA[36] array to 36 PWM registers?

    alli_264371

      Sorry for the nub question, but i never use DMA before and want to receive the 36 bytes from DMX data stream..
      I try to use UART interrupt for update PWM registers by that fast way

       

      const unsigned int PWMA[40]=

      {

          5000 ,//PWMA[0] NOT ACTUALLY, DUMMY

          5000 ,//PWMA[0] NOT ACTUALLY, DUMMY

          5000 ,//PWMA[0] NOT ACTUALLY, DUMMY

          5000 ,//PWMA[0] NOT ACTUALLY, DUMMY

          PWM_1_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_1_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_2_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_2_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_3_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_3_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_4_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_4_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_5_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_5_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_6_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_6_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_7_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_7_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_8_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_8_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_9_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_9_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_10_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_10_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_11_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_11_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_12_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_12_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_13_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_13_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_14_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_14_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_15_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_15_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_16_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_16_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_17_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_17_PWMUDB_sP8_pwmdp_u0__D1_REG ,

          PWM_18_PWMUDB_sP8_pwmdp_u0__D0_REG ,

          PWM_18_PWMUDB_sP8_pwmdp_u0__D1_REG

      };

      CY_ISR(UAR_INT)

      {

          if(ADRR<37)

          {

              if(DMADDR[dmxcount]==dmxcount)  CY_SET_REG8( (PWMA[dmxcount]),UART_RXDATA_REG);

             ADRR++;  

          }

         dmxcount++;

      }

       

      But anyway it no so fast and after correct receiving of 9 bytes I lost bytes 10, 11 ..etc ,,

       

      So I connect the DMA component to break interrupt, and configure

       

      CY_ISR(UAR_INT)

      {

         Received[dmxcount]=UART_RXDATA_REG;

         dmxcount++;

      }

       

      void DMA_Config()

      {

          /* Defines for DMA_1 */

          #define DMA_1_BYTES_PER_BURST 36

          #define DMA_1_REQUEST_PER_BURST 1

          #define DMA_1_SRC_BASE (CYDEV_SRAM_BASE)

          #define DMA_1_DST_BASE (CYDEV_PERIPH_BASE)

      /* 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 */

       

       

          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], 2, DMA_1_TD[0], 0);

          CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)Received[dmxcount]), LO16((uint32) (PWMA[dmxcount])));

          CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);

          CyDmaChEnable(DMA_1_Chan, 1);

      }

      But nothing care, all of the PWM outputs are 0..