Forum Discussion
Altera_Forum
Honored Contributor
16 years agoOh sorry, I didn't see the des in your IOWR macro.
The problem if you read directly des[x] is that the data will be read from the data cache instead of main RAM, and the cache isn't updated by the DMA. One way to get around it is to use the remap function. This should work:#include"system.h"
# include<stdio.h>
# include"altera_avalon_dma_regs.h"
# include"altera_avalon_pio_regs.h"
# include"alt_types.h"
#include "sys/alt_cache.h"
alt_u8 tab={'a','b','c','d','e','f','g','h'},des;
alt_u32 flag;
int main()
{
alt_u8 *uncached_des = (alt_u8*) alt_remap_uncached(des,8);
IOWR_ALTERA_AVALON_DMA_STATUS(DMA_BASE,0X00);
IOWR_ALTERA_AVALON_DMA_RADDRESS(DMA_BASE,tab);
IOWR_ALTERA_AVALON_DMA_WADDRESS(DMA_BASE,des);
IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_BASE,8);
IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_BASE,0X289);
while(1)
{
if(0X01&IORD_ALTERA_AVALON_DMA_STATUS(DMA_BASE))
{
IOWR_ALTERA_AVALON_PIO_DATA(PIO_BASE,uncached_des);
}
}
return 0;
}