2021-07-22 07:46 AM
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
2021-07-23 12:47 PM
>>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..
2021-07-23 12:53 PM
2021-07-24 01:16 AM
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.
2021-07-24 04:54 AM
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.
2021-07-24 05:01 AM
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.