DMA data in memory - how to assign array in C?

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

cross mob
User8734
Level 4
Level 4
Good day,

It shall be a lamer question. 😮
Meanwile, after DMA data transfer completed,
I have data in defined memory area, say 0x8000000.

How I can get this data afterwords for processing in C?

I suppose I need define (volatile) array, wich must be placed exact in same area of memory.
How it can be done?

Thanks in advance,
Konstantin
0 Likes
6 Replies
lock attach
Attachments are accessible only for community members.
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Sorry that I might not understand your question fully.

So after a successful DMA transfer, it will trigger an interrupt which you can read the memory directly as shown below.



uint8_t destination_buffer[100];

void DMA_ISR (void)
{
Block_transfer_Cnt++;

//example
if (destination_buffer[0] == 0)
{

}

if (destination_buffer[1] == 0xAA)
{

}

}
0 Likes
User8734
Level 4
Level 4
Good day Travis,

Thanks.
I know that data can be taken after DMA interrupt directly.

I suppose:

- define array exactly in place where DMA data will be transferred aftewards
- transfer data using DMA in that place
- on DMA interrupt array will be fullfilled already then, so you save time

Is it possible?


BR
K
0 Likes
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
XmCfAn2014 wrote:
Good day Travis,

Thanks.
I know that data can be taken after DMA interrupt directly.

I suppose:

- define array exactly in place where DMA data will be transferred aftewards
- transfer data using DMA in that place
- on DMA interrupt array will be fullfilled already then, so you save time

Is it possible?


BR
K




- define array exactly in place where DMA data will be transferred aftewards

Yes, you can define an array eg. destination[8] and state the destination address. So sorry that I do not understand what you mean. Maybe you can describe more in details.
0 Likes
User8734
Level 4
Level 4
Good day Travis,


No need to sorry:cool:, thanks for your support,
I really apprechiate it!!!

So, for example:

- I define array destination[8] //It is clear for me
- next, I shall somehow "assign" it to be placed in certain memory area //So, how I can do it?

BR
K
0 Likes
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
XmCfAn2014 wrote:
Good day Travis,


No need to sorry:cool:, thanks for your support,
I really apprechiate it!!!

So, for example:

- I define array destination[8] //It is clear for me
- next, I shall somehow "assign" it to be placed in certain memory area //So, how I can do it?

BR
K


Hi,

So sorry that I do not have a graceful solution to this programming, maybe you can use pointer to help you. I am also looking on how to mapped array to a specific memory location.

BR
Travis
0 Likes
nisheedhnaduvil
Employee
Employee
Hi Konstantin,

"Meanwile, after DMA data transfer completed,
I have data in defined memory area, say 0x8000000
How I can get this data afterwords for processing in C?

"

To access the DMA transferred data in location starting at 0x80000000, why can't you use the pointer?
For eg:
#define DATA_COUNT 100
uint32_t arr[DATA_COUNT];

for(uint8_t i = 0;i < DATA_COUNT;i++)
{
arr = *(uint32_t*)(0x80000000 + i);
}

DATA_COUNT is the number of DMA data words.

regards,
Nisheedh
0 Likes