Could you please explain how to use GDMA Descriptor mode?

, Jan 21, 2025|
0
129
5

I need guidance or a sample for using GDMA Descriptor mode.

I implemented the code as shown below, but it is not working.
I would greatly appreciate your assistance in identifying the issue or providing a working example.

(This code was created based on the manual and is not an official sample code.)

Below is the code provided in the programming guide reference.

#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "N9H30.h"
#include "sys.h"

#define BASE            0xB0004000
#define GDMA_DADR0      (BASE+0x1C)
#define GDMA_INTCS      (BASE+0xA0)

typedef struct struct_dma_desc
{
        unsigned int nextDescAddr;
        unsigned int srcBufAddr;
        unsigned int dstBufAddr;
        unsigned int comInfo;
} GDMA_DESC;


void main(void)
{
        unsigned int listaddr = 0x100000, i;
        GDMA_DESC *descp0 = (GDMA_DESC *)listaddr;

        for(i = 0; i < 10; i++)
        {
                descp0->nextDescAddr = 0x0A; // <- Why does this value go here?
                descp0->srcBufAddr   = 0x200000 + (0x10*4*i);
                descp0->dstBufAddr   = 0x300000 + (0x10*4*i);
                descp0->comInfo      = 0x412401;
                descp0++;
        }

        descp0--;
        descp0->nextDescAddr = 0x04;    // <- Why does this value go here?
                                        // nextDescAddr is a variable for next descriptor address.
                                        // Why is 0x04 being used?

        *((volatile unsigned int *)GDMA_DADR0) = listaddr | 0x0A; // <- Descriptor Address field of GDMA_DADR is [31:4]. Why is it like this?

        while(!(*((volatile unsigned int *)GDMA_INTCS) & 0x100));
        *((volatile unsigned int *)GDMA_INTCS) = 0x100;
}


Reply

  • Hi,

    What chip are you using?

    Danny

    I am using N9H30.

    I didn't see the driver and sample code in there BSP, where you get it like GDMA_Manager_t  ?

    https://github.com/OpenNuvoton/N9H30_NonOS/tree/master

    I created this code myself, referring to the reference manual, but it doesn't work. There is no official BSP GDMA sample available for the N9H30.

    Thanks, I saw you upload your project. I'll check it soon.