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.

how use dma receive uart uncertain length character string.



when PC string to DSP via serial port,they 's length is different.DSP use edma to receive,Howere ,how I should config the edma to deal them together.that means,how can I know the string is end?give me  a example about the edma receive uart data.

The IC is,c6747.

good luck! thanks.

  • The point of the EDMA (or DMA in general) is to offload data movement tasks into dedicated hardware.  However, this operates with some critical, minimum constraints.  These are a known source address, destination address, how and if to increment these upon every element transfer, and how many elements to transfer.  This is information that is needed before the DMA channel can be started.

    If the lenght of the stream of data on the serial port is not known a priori, then the total element size would be 1 to ensure we have the main CPU handle it properly.  However, that defeats the purpose of the DMA.

    I'm not sure I know how to help you resolve this with DMA.

  • If the element size is 1,in other words,aCnt=1,bCnt=1,cCnt=1,the destination address point to a buf,named rx_buf[64].

    all character is placed in the buf start location ,it have a question that front element will be covered following character.

  • There is a configuration of the DMA channel that allows for the destination address pointer to be incremented after the element transfer.

  • memset(tx_buf,0,sizeof(tx_buf));

    EDMA3ccRegs->DRA[1].DRAE = 1<<12;

    EDMA3ccRegs->DMAQNUM[1]  = 0x00010000 ;
     EDMA3ccRegs->PARAMSET[12].OPT = 0x0010C000;
     EDMA3ccRegs->PARAMSET[12].SRC = (Uint32)(&(Uart2Regs->RBR)); 
     EDMA3ccRegs->PARAMSET[12].A_B_CNT = _pack2(1, 1);
     EDMA3ccRegs->PARAMSET[12].DST = (Uint32)rx_buf;
     EDMA3ccRegs->PARAMSET[12].SRC_DST_BIDX = _pack2(1, 0);
     linkAddr = (Uint16)&(EDMA3ccRegs->PARAMSET[126]);
     EDMA3ccRegs->PARAMSET[12].LINK_BCNTRLD = _pack2(1, linkAddr); 
     EDMA3ccRegs->PARAMSET[12].SRC_DST_CIDX = _pack2(0, 0);
     EDMA3ccRegs->PARAMSET[12].CCNT = 1;

     EDMA3ccRegs->PARAMSET[126].OPT = 0x0010C000;
     EDMA3ccRegs->PARAMSET[126].SRC = (Uint32)(&(Uart2Regs->RBR));
     EDMA3ccRegs->PARAMSET[126].A_B_CNT = _pack2(1, 1);
     EDMA3ccRegs->PARAMSET[126].DST = (Uint32)rx_buf;
     EDMA3ccRegs->PARAMSET[126].SRC_DST_BIDX = _pack2(1, 0);
     linkAddr = (Uint16)&(EDMA3ccRegs->PARAMSET[126]);
     EDMA3ccRegs->PARAMSET[126].LINK_BCNTRLD = _pack2(1, linkAddr); 
     EDMA3ccRegs->PARAMSET[126].SRC_DST_CIDX = _pack2(0, 0);
     EDMA3ccRegs->PARAMSET[126].CCNT = 1;
     BCACHE_invalidate((Ptr)rx_buf, sizeof(rx_buf));

     //清除事件
     EDMA3ccRegs->EECR = 1<<12;
     EDMA3ccRegs->ECR  = 1<<12;
     EDMA3ccRegs->EESR = 1<<12;
     //使能中断 
     EDMA3ccRegs->IESR = 1<<12;

    Is all right like this?It doesn't incremented for destination address.PC send a serial character,only receive the last character int the rx_buf[0].

    How I should modify it?

  • What may be helpful here is to use the EDMA LLD driver APIs to accomplish this.  Have you checked into this yet?