cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
174 Views
Registered: ‎02-10-2019

AXI DMA data transfer Error (Simple transfer mode)

Hi,

I have a counter which dumps data into a fifo of width 1024 and counter length 512.

I want to trasfer data from Fifo to PS using AXI DMA.

My DMA is configured for simple mode transfer.. 

- width of Buffer length Register =14

-Max Burst size = 128

-Allow Unalinged Transfer [Enabled] 

-all others are left as default.

-only wright channel is enabled

-address with 32 bits

 

this is the program i am using 

#define MEM_DDR_ADDR 0x01000000

#define C_BASE_ADDR 0x40400000

#define S2MM_DMACR C_BASE_ADDR + 0x30
// S2MM_DMASR S2MM DMA Status register
#define S2MM_DMASR C_BASE_ADDR + 0x34
// S2MM Destination Address. Lower 32 bit address.
#define S2MM_DA C_BASE_ADDR +0x48
// S2MM Destination Address. Upper 32 bit address.
#define S2MM_DA_MSB C_BASE_ADDR + 0x4c
// S2MM Buffer Length (Bytes)
#define S2MM_LENGTH C_BASE_ADDR + 0x58

#define INTR_ID XPAR_FABRIC_AXI_DMA_0_S2MM_INTROUT_INTR

void resetDMA(void)
{
    Xil_Out32(S2MM_DMACR, 0x00000004);
}

uint32_t getIOCIRQU(void)
{
    return Xil_In32(S2MM_DMASR) & 0x5000;
}

void clearIOCIRQU(void)
{
    uint32_t value = Xil_In32(S2MM_DMASR);
    value |= 0x5000;
    Xil_Out32(S2MM_DMASR, value);
}

void setIOCIRQU(void)
{
    uint32_t value = Xil_In32(S2MM_DMACR);
    value |= 0x00007000;
    Xil_Out32(S2MM_DMACR, value);
}

void startDMA(void)
{
    uint32_t reg = Xil_In32(S2MM_DMACR);
    reg |= 0x00000001;
    Xil_Out32(S2MM_DMACR, reg);
}

void stopDMA(void)
{
    uint32_t reg = Xil_In32(S2MM_DMACR);
    reg &= 0xfffffffe;
    Xil_Out32(S2MM_DMACR, reg);
}

uint32_t hasSG(void)
{
    return Xil_In32(S2MM_DMASR) & 0x00000008;
}

uint32_t getS2MMLAddr(void)
{
    return Xil_In32(S2MM_DA);
}

uint32_t getS2MMHAddr(void)
{
    return Xil_In32(S2MM_DA_MSB);
}

void setS2MMLAddr(uint32_t value)
{
    Xil_Out32(S2MM_DA, value & 0xffffffff);
}

void setS2MMHAddr(uint32_t value)
{
    return Xil_Out32(S2MM_DA_MSB, value & 0xffffffff);
}

uint32_t getS2MMLenght(void)
{
    return Xil_In32(S2MM_LENGTH);
}

void setS2MMLenght(uint32_t value)
{
    Xil_Out32(S2MM_LENGTH, value & 0x1ffffff);
}

int main()
{
    uint32_t s2mmLAddr = 0;
    uint32_t s2mmHAddr = 0;
    uint32_t s2mmLenght = 0;
    uint8_t sgIncluded = 0;

    init_platform();

    for(uint32_t i = 0; i < 100; i++)
        printf("\r\n");

    sgIncluded = hasSG();
    printf("********* In [ %s ] *********\r\n", __FUNCTION__);
    printf("SG %s included\r\n", (sgIncluded) ? "is":"is not");

    s2mmLAddr = getS2MMLAddr();
    s2mmHAddr = getS2MMHAddr();
    s2mmLenght = getS2MMLenght();

    startDMA();
    setIOCIRQU();

    printf("DMA Control Register = 0x%.8lx\r\n", Xil_In32(S2MM_DMACR));

    setS2MMLAddr(MEM_DDR_ADDR);
    setS2MMHAddr(0x3fffffff);

    s2mmLAddr = getS2MMLAddr();
    s2mmHAddr = getS2MMHAddr();
    setS2MMLenght(0x000001ff);
    s2mmLenght = getS2MMLenght();

    printf("Register length = 0x%.8lx\r\n", s2mmLenght);
    printf("Low Address = 0x%.8lx\r\n", s2mmLAddr);
    printf("High Address = 0x%.8lx\r\n", s2mmHAddr);

    while(1)
    {
        setS2MMLenght(0x000001ff);
        uint32_t *datap = (uint32_t *) s2mmLAddr;
        while (!getIOCIRQU())
            ;
        clearIOCIRQU();

        for(uint8_t i = 0; i < 8; i++)
        {
            printf("@%.8lx => data[%02d] = 0x%.8lx\r\n", datap, i, *datap);
            datap++;
        }
    }

    printf("********* Out [ %s ] *********\r\n", __FUNCTION__);
    cleanup_platform();
    return 0;
}

It runs for sometime if i write the length of tranfer 0x100 or higher . and gives error;
S2MM_DMASR value = 0x5011
and when i want to trasfer data again after first block it does'nt work and S2MM_DMASR value = 0x0011

Also it doesn't transfers data of lesser size say 10 or 20 bytes.

How can i configure the DMA to transfer the data of whatever size i want .
Is there any example i can refer?
i also want to capture the completion interrrupt and transfer data accordingly ,please help

 

Tags (3)
0 Kudos