This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTI DMA request

Other Parts Discussed in Thread: HALCOGEN

Hi,

I'm working with a TMDX570LS31HDK and trying to implement a DMA transfer driven by RTI. The goal (for now) is to see the DMA transferring data from a buffer (TX_DATA in the code) to a single 8 bit location. The trnsfer should be 1 byte a time and should continue indefinetly (so should cycle TX_DATA ).

Here's my sysmain. Note: the Halcogen setup should be right because I see a debug message from the RTI IRQ function (not reported here)

#define D_SIZE 512
uint8 TX_DATA[D_SIZE];     /* DMA source buffer */
g_dmaCTRL g_dmaCTRLPKT;

sciInit();
rtiInit();
rtiEnableNotification(rtiNOTIFICATION_COMPARE0);

/* write some value on the source buffer just to see if something changes */
int i;
for (i=0;i<D_SIZE;i++){
    if (i%2==0) TX_DATA[i]=0x00;
    else TX_DATA[i]=0xff;
}


uint8 DMA_dest; /* DMA destination */

/* - assigning dma request: channel-0 with request line 12, should be the RTI, right? */
dmaReqAssign(0,12);

/* - configuring dma control packets   */
g_dmaCTRLPKT.SADD      = (uint32)&TX_DATA;  /* source address             */
g_dmaCTRLPKT.DADD      = (uint32)&DMA_dest;       /* destination  address       */
g_dmaCTRLPKT.CHCTRL    = 0;                 /* channel control            */
g_dmaCTRLPKT.FRCNT      = 1;                 /* frame count                */
g_dmaCTRLPKT.ELCNT     = D_SIZE;            /* element count              */
//g_dmaCTRLPKT.ELDOFFSET = 0;      /* element destination offset - is required?      */
// g_dmaCTRLPKT.ELSOFFSET = 0;      /* element source offset   - is required?           */
//g_dmaCTRLPKT.FRDOFFSET = 0;      /* frame detination offset  - is required?          */
//g_dmaCTRLPKT.FRSOFFSET = 0;      /* frame source offset   - is required?             */
g_dmaCTRLPKT.PORTASGN  = 4;                 /* port b                     */
g_dmaCTRLPKT.RDSIZE    = ACCESS_8_BIT;       /* read size                  */
g_dmaCTRLPKT.WRSIZE    = ACCESS_8_BIT;        /* write size                 */
g_dmaCTRLPKT.TTYPE     = FRAME_TRANSFER ;   /* transfer type              */
g_dmaCTRLPKT.ADDMODERD = ADDR_INC1;         /* address mode read          */
g_dmaCTRLPKT.ADDMODEWR = ADDR_FIXED;        /* address mode write         */
g_dmaCTRLPKT.AUTOINIT  = AUTOINIT_ON;       /* autoinit  (loop)           */
//g_dmaCTRLPKT.COMBO;      /* I don't think is required, right?   */

/* - setting dma control packets */
dmaSetCtrlPacket(DMA_CH0,g_dmaCTRLPKT);

/* - setting the dma channel to trigger on h/w request */
dmaSetChEnable(DMA_CH0, DMA_HW);

rtiREG1-> SETINT = (0x01U << 8);

_enable_IRQ();
rtiStartCounter(rtiCOUNTER_BLOCK0);

/* the loop here is just to test is something changes in the destination */
uint8 DMA_compare=DMA_dest;
while(1){
    if (DMA_compare!=DMA_dest){
        sciDisplayText("dest changed",sizeof("dest changed"));
        DMA_compare=DMA_dest;
    }
}


Is there's some errors? (fore sure: it doesn't works!)

Thank you,

Matteo

  • Hi Matteo,

    just a quick glance.  i don't see where you initialize DMA_dest to SPI data register.

  • Hi Matteo,

        There are something wrong with your configuration of DMA module. Since you want to transfer  data from a buffer to a 8 bits location. In order to get every data from the source, you should change the FRAME COUNT equals D_SIZE and ELEMENT COUNT equals 1. and alao I suggest you enable the offset parameters of frame and element(if not, that's also OK, because the default values are 0). You can check the following codes which are tested and working well.

    void main(void)
    {
    /* USER CODE BEGIN (3) */
    dmaEnable();
    load_data();
    /* - configuring dma control packets */
    g_dmaCTRLPKT.SADD = (uint32)&TX_DATA; /* source address */
    g_dmaCTRLPKT.DADD = (uint32)&DMA_dest; /* destination address */
    g_dmaCTRLPKT.CHCTRL = 0; /* channel control */
    g_dmaCTRLPKT.FRCNT = D_SIZE; /* frame count */
    g_dmaCTRLPKT.ELCNT = 1; /* element count */
    g_dmaCTRLPKT.ELDOFFSET = 0; /* element destination offset - is required? */
    g_dmaCTRLPKT.ELSOFFSET = 0; /* element source offset - is required? */
    g_dmaCTRLPKT.FRDOFFSET = 0; /* frame detination offset - is required? */
    g_dmaCTRLPKT.FRSOFFSET = 0; /* frame source offset - is required? */
    g_dmaCTRLPKT.PORTASGN = 4; /* port b */
    g_dmaCTRLPKT.RDSIZE = ACCESS_8_BIT; /* read size */
    g_dmaCTRLPKT.WRSIZE = ACCESS_8_BIT; /* write size */
    g_dmaCTRLPKT.TTYPE = FRAME_TRANSFER ; /* transfer type */
    g_dmaCTRLPKT.ADDMODERD = ADDR_INC1; /* address mode read */
    g_dmaCTRLPKT.ADDMODEWR = ADDR_FIXED; /* address mode write */
    g_dmaCTRLPKT.AUTOINIT = AUTOINIT_ON; /* autoinit (loop) */
    dmaSetCtrlPacket(DMA_CH0,g_dmaCTRLPKT);
    dmaSetChEnable(DMA_CH0, DMA_HW);
    dmaReqAssign(0,12);

    rtiInit();
    rtiStartCounter(rtiCOUNTER_BLOCK0);
    rtiREG1-> SETINT = (0x01U << 8);
    rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
    rtiStartCounter(rtiCOUNTER_BLOCK0);
    _enable_IRQ();
    while(1)
    {


    }

    Ken Wang

    Thanks and Best Regards!

  • Hi Henry,

    thank you for the answer but why should I initialize SP?. The SPI is no involved here.

    Matteo

  • Hi Ken,

    thank you very much for the correction. It works as expected

    Problem solved.

    Matteo

  • Hi Matteo,

    i apologize misreading the message.  I was quickly glance at the code and did not see the dest addr initialize to a known value.  But you are right.

  • No problems. Thank you.