Forum Discussion
111 Replies
- Altera_Forum
Honored Contributor
So the DMA seems to work.
Why are you setting every register double time? Why are you setting it to different values? e.g the control register is first set to constant write address, then to constant read address. When you start the transaction, you set it again to constant write address, then start it again with constant read address. If the DMA was not finished at that time, your code might confuse it during operation... You can read these register as often as you like, but you should only need to write them only once. The values should not change until the DMA is really started, even afterwards most of them should still read the same values. - Altera_Forum
Honored Contributor
I am quite confuse with the register as well. But I am using two different DMA in the system. One is for memory to peripheral and another is for peripheral to memory. Do you mind suggest me a solution? thanks!
- Altera_Forum
Honored Contributor
oh, i didn't see there's 2 base addresses DMA_BASE and DMA_0_BASE.
So then it should be ok.... - Altera_Forum
Honored Contributor
Haha, I think I got it...
your "random" numbers don't seem so random to me.... 131072 = 0x20000 393220 = 0x60004 655368 = 0xA0008 917516 = 0xE000C and so on... Is either of your RAM or your periphereal 16bit wide? Instead of doing a IORD(dst,i) try doing a IORD_16DIRECT(), that shoud do the trick... Edit: Maybe you must do IORD_16DIRECT(dst, i*2), because it might use a byte offset. IORD() itself already converted the offset to bus width, which it thought being 32bit. - Altera_Forum
Honored Contributor
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 --- - Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
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 ;-))) - Altera_Forum
Honored Contributor
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?
- Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
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.