How to use DMAMUX generated events to trigger another DMA request?

28 views Asked by At

I want to send data to UART using DMA. Every 3 transfers I want to generate another DMA request (without using core) to transfer data from the timer CNT register to memory. The documentation of the DMAMUX is generally impossible to understand. They have lines and signals which are not connected to anything.

Tis figure shows that it is possible. enter image description here

The DMAMUX request generator generates the request which can be used by another DMAMUX channel and routed to the actual DMA

The code (minimal example):

  DMA1_Channel2 -> CNDTR = 10;
  DMA1_Channel2 -> CPAR = (uint32_t)&TIM15 -> CNT;
  DMA1_Channel2 -> CMAR = (uint32_t)data16;

  DMA1_Channel1 -> CNDTR = 6;
  DMA1_Channel1 -> CMAR = (uint32_t)data;
  DMA1_Channel1 -> CPAR = (uint32_t)&LPUART1 -> TDR;

  DMAMUX1_Channel0 -> CCR = DMA_REQUEST_LPUART1_TX | DMAMUX_CxCR_EGE | (2 << DMAMUX_CxCR_NBREQ_Pos);

  DMAMUX1_Channel1 -> CCR = DMA_REQUEST_GENERATOR0;

  DMAMUX1_RequestGenerator0 -> RGCR = DMAMUX_RGxCR_GPOL_Msk  | (0 << DMAMUX_RGxCR_GNBREQ_Pos);
  DMAMUX1_RequestGenerator0 -> RGCR |= DMAMUX_RGxCR_GE;

  DMA1_Channel1 -> CCR |= DMA_CCR_EN;
  DMA1_Channel2 -> CCR |= DMA_CCR_EN;
  LPUART1 -> CR3 |= USART_CR3_DMAT;

But unfortunately, it transfers the data to the LPUART, but does not generate the events which can be consumed by by the DMAMUX channel1.

Is it doable? What am I doing wrong?

Link to RM from page 396

1

There are 1 answers

0
gulpr On

Eventually, I have found the solution.

The MAMUX1_RequestGenerator0 -> RGCR SIG_ID field has to be set to correct "synchronization inputs to resource" (Table 58 in RefMan)

So this line will become

  DMAMUX1_RequestGenerator0 -> RGCR = DMAMUX_RGxCR_GPOL_Msk  | (0 << DMAMUX_RGxCR_GNBREQ_Pos) | (16 << DMAMUX_RGxCR_SIG_ID_Pos);

(16 as it is dmamux_evt0 signal)