Regarding DMA transfer

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 In a project , I have configured DMAs TD to transfer 3 bytes of data.

   

The source is uint8 Temp_Data[0], basically an array of "2" bytes and i am icrementing source address on transfer.

   

Now is there any problem if mysource is an array less than the no, of bytes to be transferred. 

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

As long as the DMA reads from source there will be no error when reading behind a defined variable, althoug the result might be unpredictable.

   

 

   

Bob 

0 Likes
Anonymous
Not applicable
AkashGupta
   

Why do configure your TD to transfer 3 bytes of data when the size of array declared is just 2? For DMA, just the starting address pointer is important. It will just keep of incrementing the source pointer and transfer the content in it as configured.

0 Likes
Anonymous
Not applicable

 The question was I have configured an array of 2 bytes and trying to transfer 3 bytes from this array. So wil there be any problem for the DMA . I know it doesn't as the array address will just represent some location in SRAM and as the address increments DMA will take data from that location and transfers until it is done with the transfer.

   

I am not finding any problem but just the received byte is junk

0 Likes
Anonymous
Not applicable

 The question was I have configured an array of 2 bytes and trying to transfer 3 bytes from this array. So wil there be any problem for the DMA . I know it doesn't as the array address will just represent some location in SRAM and as the address increments DMA will take data from that location and transfers until it is done with the transfer.

   

I am not finding any problem but just the received byte is junk

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

The DMA unit doesn't care, and doesn't even know, about your array definition. It just does know about RAM (or flash, or other types of where it can read and write stuff from and to), and just does what you tell it to do.

   

So when you array is only 2 elements large, and you tell the DMA to transfer 3 bytes, it will happily do what you say, and transfer the byte directly behind your array from memory. It most likely will be garbage, since the compiler normally aligns all variables on a 4 or 8 byte addresses.

0 Likes