- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, may I know how to transfer data from peripheral to memory using DMA? It is quite confusing from memory-to-memory transfer. please help! thanks!
- Tags:
- Include
Link Copied
- « Previous
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes.. my RAM (both SRAM and SDRAM) is 16 bit, peripheral is 32 bit and DMA is 32 bit as well... so for the IOWR during writing into source (SDRAM), do i have to use IOWR_16DIRECT?
update: now, initially... i use.. for(i=0; i<100; i++) { IOWR(src, i, i); printf("initial: %d\n", IORD(src, i)); } //same DMA code for(i=0; i<100; i++) { printf("end: %d\n", IORD_16DIRECT(dst, i*2)); } and the result... it is ok to for 0 until 49, then the rest all is 1. --- Quote Start --- end: 0 end: 1 end: 2 end: 3 end: 4 end: 5 end: 6 end: 7 end: 8 end: 9 end: 10 . . . end: 39 end: 40 end: 41 end: 42 end: 43 end: 44 end: 45 end: 46 end: 47 end: 48 end: 49 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 end: 0 --- Quote End ---- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I know why. Correct me if I am wrong...
1 number = 4 bytes and the length of the DMA is 200, which means 200 bytes. So, the DMA will transfer 200bytes of data (equivalent to 50 numbers only, 200bytes/4bytes = 50). So, DMA will write 0-49 only. Am I right? Besides, how many bits are there in 1 address location? 32bit? What does it mean when SDRAM has 16bit data width, meaning 1 address of SDRAM has 16bit? If the source is 32bit, one fetch of data from the source is 32bit(store in 1 address of the source) but when reach SDRAM which is 16bit, it needs 2 address location to store the 32bit data from source. Am I correct? update: seem like the transfer has some problem. in the source, there is 200 numbers, but after transfer to peripheral then to memory again, the number is less than 200.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hm.
That sounds plausible. Good to see it's working at all finally ;-))) As for the 16bit/32bit problem: would it be a solution to just set the DMA to Halfword (16bit) mode? You don't need the upper 16bits of the data anyway... Or do you need to add 32bit values too? I'm not an expert in DMA, so I'm not certain how the DMA does 32/16bit conversion. There should be some explanation in the manual. I think it's up to you now to play with the settings to make it perfect ;-)))- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yeah. it is working now. I think i know the problem. the setting you taught is correct. problem is with my peripheral which is FIFO. I set it to be 256 words initially, which is 512byte only. so the most it can fit 128 numbers, as 1 number is 4 byte. if i transfer more than 128 number, it will stop at 128 and the rest will be 0 and it will be full... i dont have reset signal for FIFO if it is full. so i think it is the problem. am i right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the last picture you posted, the Fifo was 32bitx256, so there should be 256 values.
Maybe there was not enough data fed in? Otherwise, I have no idea.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i tried 100 numbers and it works. then when i try 150numbers, it manage to fetch till 128. so i guess, since 1 number = 4 byte, and 256words = 512bytes, so it can fill in 128 numbers only. but i tried to increase the size, and i am using Cyclone II, it has limit for internal memory. so i guess i will use small data size to transfer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi soonph87, I have a similar problem to what you had before. I am trying to use data coming from two arrays generated in NIOS and do a simple calculation with them in hardware. I posted a thread earlier and I was told to try a FIFO/DMA but I am getting lost! See link below
http://www.alteraforum.com/forum/showthread.php?t=29030 Could you please post here on forum or email me your project so that I can learn the procedure step by step by going though the SOPC builder, NIOS, peripheral code? For me too, I am doing this as an exercise to learn how to manipulate data for a future image processing task but I am stuck in the starting blocks! Please be assured that I am not gonna use that for any commercial advantage :) I just want to learn but finding the right learning material is so so difficult. Thank you for your consideration.![](/skins/images/45C6C2D737ED71F4C51F0145C8CB1E9C/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
- Next »