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

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
alli_264371
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

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..


I cannot confirm email and add messages due to a bug on your site, the email section is not active
0 Likes
1 Solution
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Alex,

The following link have DMA based example codes you can refer to. https://www.cypress.com/documentation/code-examples/psoc-345-code-examples

If you can share your project, we could check what is going wrong in your code.In PSoC Creator ,  go to File -> Create Workspace Bundle -> Select minimal. Please attach the generated file.

Best Regards,
Vasanth

View solution in original post

3 Replies
alli_264371
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Also I not see the "Peripheral" option in DMA wizard of PSOC3 at all..only SRAM..It mean I can't use DMA in PSOC3 to transfer data to PWM?Kahu_Product_Page_iPhone_TabA.png


I cannot confirm email and add messages due to a bug on your site, the email section is not active
0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Alex,

The following link have DMA based example codes you can refer to. https://www.cypress.com/documentation/code-examples/psoc-345-code-examples

If you can share your project, we could check what is going wrong in your code.In PSoC Creator ,  go to File -> Create Workspace Bundle -> Select minimal. Please attach the generated file.

Best Regards,
Vasanth

Thank you Vasanth
I'm have increase the master clock to 48MHz, and now can solve it without the DMA .


I cannot confirm email and add messages due to a bug on your site, the email section is not active
0 Likes