Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D DMA transfer expected behaviour #394

Open
bpervan opened this issue Jul 6, 2023 · 0 comments
Open

2D DMA transfer expected behaviour #394

bpervan opened this issue Jul 6, 2023 · 0 comments

Comments

@bpervan
Copy link

bpervan commented Jul 6, 2023

Hi,

I'm doing some experiments which employ a 2d DMA transfer by invoking rt_dma_memcpy_2d. I'm genuinely unsure if I'm missing something or if the result might be wrong. I can't find any example whatsoever which demonstrates the utilization of the 2d DMA transfers in the codebase.

Consider the following minimal example:

Original array (5x3)
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

For the sake of simplicity, the data type of the array elements is uint8. Now, let's assume that I want to copy this array and place it within a larger array (7x5 of uint8) which has previously been memset to 0.

Now, with stride = 5 which is the width of the source matrix, and length = 7 which is the width of the destination matrix, and by offsetting the destination address by 8, I would expect to end up with something like this:

0 0 0 0 0 0 0
0 1 2 3 4 5 0
0 1 2 3 4 5 0
0 1 2 3 4 5 0
0 0 0 0 0 0 0

However, what I end up with is this:

0 0 0 0 0 0 0
0 1 2 3 4 5 1
2 1 2 3 4 5 1
2 1 0 0 0 0 0
0 0 0 0 0 0 0

The API call is:
rt_dma_memcpy_2d((unsigned int) l2data, (unsigned int) l1data + 8, 3 * 5 * sizeof(uint8_t), 5, 7, RT_DMA_DIR_EXT2LOC, 0, &L2toL1);

What am I missing here? Might it be that I somehow miscomprehended the idea of 2d DMA transfers? Is it possible to employ 2d DMA transfers to achieve the expected behaviour?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant