cancel
Showing results for 
Search instead for 
Did you mean: 

Hello !!! Some strange error occured when I've tried to transfer a block data. First, Ithe processor received (by serial-DMA) 2006 bytes each time and this is repeated for 240 times resulting an array of 480,000 bytes

INaka.1
Associate III

The processor is the STM32L4R5 and the SMT32CubeIDE versin 1.6.

uint16_t US_Cksum,Trans_Pointer,USA_Data[2006],US_Trans[480000];

uint32_t US_Pointer;

US_Pointer is zeroed at the start of the program

US_Cksum=0;// For Checksum

Trans_Pointer=4;

  while(Trans_Pointer<2004){

  US_Trans[US_Pointer]=USA_Data[Trans_Pointer];

  US_Cksum+=USA_Data[Trans_Pointer];

  US_Pointer++;

  Trans_Pointer++;

}

The question is: Why the US_Cksum doesn't generate a correct sum?

Thank you

14 REPLIES 14

>>But, when a receive this buffer through DMA- USART, the buffer is correct, but the check sum has a strange value.

Math or data is wrong.

>>Now, I need to discover how much time I need to wait.

Doesn't the UART DMA have a call back that indicates the last byte was received.

Flag that in a volatile variable, and wait on it, or do the checksum/dispatch in the call-back..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
What interrupt? The memory should be populated after transfer complete.
If you feel a post has answered your question, please click "Accept as Solution".
MM..1
Chief II

Maybe you dont understand DMA

HAL_UART_Receive_DMA(&huart1,USA_Data,2006); Am I wrong ?

is only start operation , this not wait to data end , DMA is for MCU offload then code continue immediately and no data is received at that moment.

Your code here can do other things and Cortex provide two IRQ one for half buffer received and second for full buffer.

In this two IRQ callbacks you need move data calc anything usw.

INaka.1
Associate III

Hello my friend... You know, I'm a beginner with STM32. What i do is prepare the DMA UART receive interrupt and wait for a interruption inside the" stm32l4xx_it.c". I didn't know that the DMA provides two interruption. Then now, I´m waiting for the second ( full buffer) and it worked properly.

Thank you again for the help!!!

Best regards.

INaka.1
Associate III

Hello Tesla. The M.M member wrote that the DMA furnish two interrupts request: at the middle and at the end. I didn't know that!! Now, I'm reading the buffer at the second one. It is working know...( happy Saturday morning )

Thank you for your help.