Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

DMA Write to Peripheral not working in Nios

Hi,

I am trying to write data onto one of the registers of a new component via the register map for DMA but seems like its not working. As of now my simplistic component just reads an 8 bit input and assigns it to an 8 bit output register which I read through the software. My DMA controller configurations are 13 bits and half word/word/byte transfer allowed.

My software code is:

alt_u8 data_in[4] = {0xef, 0x00, 0x01, 0xaf};

unsigned int sentvalue = data_in[0];

printf("sent value is = %d\n", data_in[0]);

iowr_altera_avalon_dma_status(dma_base, 0);

iowr_altera_avalon_dma_raddress(dma_base, data_in);

iowr_altera_avalon_dma_waddress(dma_base, (dummy_base + 4)); // dummy_base + 4 is the address of the write register of my component

iowr_altera_avalon_dma_length(dma_base, 1);

iowr_altera_avalon_dma_control(dma_base,0x000002e9);

while (0x01 & iord_altera_avalon_dma_status(dma_base) == 0) { }

unsigned long returnval = iord_8direct(dummy_base, 8); // dummy_base + 8 is my read register for the component

printf("received value is = %d compared to sent value is = %d\n", returnval, sentvalue);

I get some junk output here as:

Sent Value is = 239

Received Value is = 255 compared to sent Value is = 239.

Needless to say I expect the return value to be "239" as well.

For the component connection in SOPC I have connected the read and write master to sram controller's s1 and my component slave port.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Any help any update? I am still stuck with the problem, whether I read a byte/half-word/word, I always get a junk value "all Fs"