cancel
Showing results for 
Search instead for 
Did you mean: 

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

JNoon.1
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
JNoon.1
Associate III

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.

View solution in original post

2 REPLIES 2
FBL
ST Employee

 

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.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


I'm out of offce with limited access to my emails.
Happy New Year!
JNoon.1
Associate III

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.