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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 7: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
- Labels:
-
DMA
-
STM32CubeProgrammer
-
STM32L4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 7:56 AM
When your MCU have 640K RAM you cant store 480000 16bit values result is overmemory.
Too your pointer counter and code dont doo what you write.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 11:18 AM
I'm sorry. I wrote incorrectly the declaration. Indeed the correct declaration is : uint8_t USA_Data[2006],US_Trans[480000]. So, there´re space in RAM for others variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 12:45 PM
> Why the US_Cksum doesn't generate a correct sum?
How do you know it's not correct? To what do you compare it?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 1:11 PM
Thank you for reading my question.
I forced a known buffer ( indeed I wrote 0x01 in all positions) so the Check sum must be 2000d ( or 0x07d0). I´ve looked the entire buffer, verifying if it was correct. But the Check Sum value isn´t.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-22 2:20 PM
There isn't a error in the hardware with adding numbers together.
Perhaps the code does not do what you think it does. Given you've mistyped uint16_t for uint8_t, seems like other parts of the code could also be wrong. Produce a minimal compilable example which exhibits the problem.
This is something you can very easily step through the code to verify it's adding 1 (in your forced buffer example) on each iteration. Reduce the buffer size and test. If you expect 0x7D0, What value do you get instead?
Less likely issues would be something not marked as volatile which should be.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-23 5:39 AM
Good morning. I wrote wrongly in the question uint16_t for the arrays. Indeed in the program is written correctly as"int8_t". Perhaps, this error occurs when I receive the buffer using the DMA-USART. I did the test with 100 bytes. When I forced a known buffer, the check sum is calculated correctly. But, when a receive this buffer through DMA- USART, the buffer is correct, but the check sum has a strange value.
Thank you for your attention.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-23 6:00 AM
When buffer is ok then your code calculate checksum on bad time, with DMA you need wait for transfer complete because USART is slow ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-23 12:28 PM
But, I'm waiting for the DMA interruption . I thought that this interruption occurs only when the specified amount of bytes are received -HAL_UART_Receive_DMA(&huart1,USA_Data,2006); Am I wrong ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-23 12:42 PM
Well... you're absolutely right. I put a delay ( HAL_Delay(100) after the interruption response. Then the Checksum is correct. Now, I need to discover how much time I need to wait.
Thank you very much
