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.

Trouble in getting DMA current transfer count update

I was using TMS570LS3173 for SCI RX. I used the DMA for SCI1 and SCI2(LIN). I have two size of pkts: 25B and 546B. I don't know when these pkts coming in.

    g_dmaCtrPkt.DADD = pBuff;
    g_dmaCtrPkt.FRCNT = 768;
    g_dmaCtrPkt.ELCNT = 1U;
    g_dmaCtrPkt.CHCTRL    = 0U;                 /* channel control            */
    g_dmaCtrPkt.ELDOFFSET = 0U;
    g_dmaCtrPkt.ELSOFFSET = 0U;

    g_dmaCtrPkt.FRDOFFSET = 1U;                 /* frame destination offset   */
    g_dmaCtrPkt.FRSOFFSET = 0U;                 /* frame destination offset   */
    g_dmaCtrPkt.PORTASGN = 4U;/*PortB*/
    g_dmaCtrPkt.RDSIZE = ACCESS_8_BIT;/*8bit read*/
    g_dmaCtrPkt.WRSIZE = ACCESS_8_BIT;/*8bit read*/
    g_dmaCtrPkt.TTYPE = FRAME_TRANSFER;
    g_dmaCtrPkt.ADDMODERD = ADDR_FIXED;
    g_dmaCtrPkt.ADDMODEWR = ADDR_INC1;
    g_dmaCtrPkt.AUTOINIT = AUTOINIT_OFF;

I want to use polling the Buf to rx pkts. In the firtst 2 bytes, there are flags indicate the pkt length.

I check the CTCOUNT, if CTCOUNT==pkt length  copy all bytes.

But I found that CTCOUNT can not update correctly. Could some one help me, how to update CTCOUNT val.

Many Thanks!

  • Hi user4461578 ,

    Trying to read the CTCOUNT while the DMA is operating won't work in practice.

    2 things:

    1) g_dmaCtrPkt is actually a global variable in RAM. It is the staging area for the control packet.
    it gets copied to the DMA control packet RAM.
    If the current count is *ever* updated it will not be updated in the global variable.
    It will be updated in the DMA control packet RAM.

    2) The DMA keeps an internal copy of the current control packet that's not readable.
    It is only readable when it has to be written back to the control packet RAM due to channel arbitration.
    (when the DMA has to switch to work on another channel).

    So, trying to read the CTCOUNT won't work.

    You will need to do something like handle the first few bytes separately until you know the payload length.
    Then you can setup a DMA again to transfer the payload length once it is known.

    Best Regards,
    Anthony