Skip to main content
Visitor II
October 1, 2023
Solved

Having trouble receiving more data than my USART DMA buffer is set to

  • October 1, 2023
  • 1 reply
  • 1764 views

Hi All,

I am trying to get my Nucleo-U575ZI-Q to receive low level USART data using DMA. I have set it up to be a circular buffer in the IOC file but everytime I receive 1024 bytes for example after that it won't receive anything.

When I call LL_DMA_GetBlkDataLength it gives me the space in the DMA buffer left and once it hits 0 it stays at 0. Instead of rolling around back to 1024. 

Attached is the settings for my USART1 Rx using DMA channel 0.

Any other info required please ask.

Thanks.

 

1Capture.PNG2Capture.PNG3Capture.PNG

    This topic has been closed for replies.
    Best answer by JNoon.1

    Hi @FBL,

    Thank you for your response. I have managed to find a solution.

    In the USART init function generated by CubeMX, it generates a shadow variable - LL_DMA_LinkNodeTypeDef Node_GPDMA1_Channel0 = {0};

    But this has already been generated at the top of the file as a global (not static). I had to remove this line from the init function.

    Also I used to call LL_DMA_SetDestAddress and LL_DMA_SetBlkDataLength in a separate file as my Rx buffer didn't live in main.c. Now this works on other MCs like the F722 and F446 that I have used but they don't for the U575. Instead I had to set these in the NodeConfig struct inside the USART init in main, meaning I had to get the address and size of my buffer dynamically. 

    With these changes it works. Which means the CubeMX generation is wrong. I had also had to set the SrcAddress in the same NodeConfig manually too instead of it being generated by CubeMX. If I regenerate my IOC file then I have to add these changes in, which is a real pain.

    Hopefully this makes some sense. If you want an example of my Init function before and after the changes I can add them here.

    Thanks.

    1 reply

    Technical Moderator
    October 2, 2023

     

    Hello @JNoon.1 

    Would you please share your IOC file, and your implementation?

    Please note, according to the reference manual, once the last data transfer is completed (BNDT[15:0] = 0):
    - if GPDMA_CxLLR.UB1 = 1, this field is updated by the LLI in the memory.
    - if GPDMA_CxLLR.UB1 = 0 and if there is at least one non null update bit, this field is internally restored to the programmed value.

    JNoon.1AuthorAnswer
    Visitor II
    October 3, 2023

    Hi @FBL,

    Thank you for your response. I have managed to find a solution.

    In the USART init function generated by CubeMX, it generates a shadow variable - LL_DMA_LinkNodeTypeDef Node_GPDMA1_Channel0 = {0};

    But this has already been generated at the top of the file as a global (not static). I had to remove this line from the init function.

    Also I used to call LL_DMA_SetDestAddress and LL_DMA_SetBlkDataLength in a separate file as my Rx buffer didn't live in main.c. Now this works on other MCs like the F722 and F446 that I have used but they don't for the U575. Instead I had to set these in the NodeConfig struct inside the USART init in main, meaning I had to get the address and size of my buffer dynamically. 

    With these changes it works. Which means the CubeMX generation is wrong. I had also had to set the SrcAddress in the same NodeConfig manually too instead of it being generated by CubeMX. If I regenerate my IOC file then I have to add these changes in, which is a real pain.

    Hopefully this makes some sense. If you want an example of my Init function before and after the changes I can add them here.

    Thanks.