cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F413VGT6 DMA is triggered but no data is copied

NHand
Associate II

Hello,

I'm trying to use DMA with an Usart to receive incoming data in a circular buffer. Basically this is my code for configuration using UART5. I can send data, so i assume, that port und clock configuration is correct. When receiving data, NDTR is couting down but there is no data copied into the buffer M0AR. Uart5 uses DMA1 Stream0, Channel 4. FIFOs are not used.

When i switch to polling receiving without dma, everything works. What can be the issue?

 

    dma = DMA1_Stream0;
    dma->CR &= ~DMA_SxCR_EN;
    dma->CR |= 4 << DMA_SxCR_CHSEL_Pos;    

    dma->PAR = (uint32_t)&oConfig.oUSART->DR;
    dma->M0AR = (uint32_t)&buf_rx[0];
    dma->NDTR = BUFFER_SIZE;
    dma->CR |= DMA_SxCR_PL_1;
    dma->CR |= DMA_SxCR_PL_0;
    dma->CR |= DMA_SxCR_MINC;
    dma->CR |= DMA_SxCR_CIRC;
    dma->CR |= DMA_SxCR_EN;

    oConfig.oUSART->CR1 &= ~USART_CR1_UE;
    oConfig.oUSART->CR3 |= USART_CR3_DMAR;

    oConfig.oUSART->CR1 = USART_CR1_TE | USART_CR1_RE;
    oConfig.oUSART->CR1 |= USART_CR1_UE;

    setBaudrate(oConfig.u32Baudrate);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
NHand
Associate II

I found the error myself. I use cpp and I initializied my object the wrong way, so that the adress

dma->M0AR = (uint32_t)&buf_rx[0];

is not correct anymore.
I used this and the copy constructure created a new object on a different adress. No wonder it did not work.

USARt obj;
obj = USART(UART5, 9600);

 

View solution in original post

4 REPLIES 4
TDK
Guru

Either it's a DMA setting issue, which I don't see any issues with, or maybe an issue with how you're interpreting that no data is being sent. Or maybe with UART initialization?

> setBaudrate(oConfig.u32Baudrate);

Or maybe with UART initialization? You're setting baud rate after the peripheral is enabled and receiver/transmitter enabled, that can't be right.

Do any error flags get set in the UART or DMA registers?

If you feel a post has answered your question, please click "Accept as Solution".

> maybe an issue with how you're interpreting that no data is being sent

+1

And, as always when debugging, read out and check/post content of DMA registers.

JW

 

NHand
Associate II

I found the error myself. I use cpp and I initializied my object the wrong way, so that the adress

dma->M0AR = (uint32_t)&buf_rx[0];

is not correct anymore.
I used this and the copy constructure created a new object on a different adress. No wonder it did not work.

USARt obj;
obj = USART(UART5, 9600);

 

Thanks for coming back with the solution. Please click on "Accept as solution" in that post so that the thread is marked as solved.

JW