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.

DMA to transfer 8bit ADC results

I'm having some issues with setting up the DMA to transfer results from the ADC to an address in DCAN.

I'm trying to transfer 8 x 8bit results from the ADC1 EV group FIFO at 0xFFF7C090 to a register in DCAN.  The problem I am having is that I'm not sure how to setup the DMA transfer.

What should the Read and Write size be, also the Element/frame count?

I understand the offset is in bytes but not sure how this translates.

For example I need the following:

(FIFO Output)

0x00000011

0x00000022

0x00000033

0x00000044

0x00000055

0x00000066

0x00000077

0x00000088

to be output as

0x11223344

0x55667788

or

0x44332211

0x88776655

I've tried setting the read to 8bit and write to 64bit,  frame count and element count to 8 (and 1) but I only get the most significant byte from the FIFO.

The examples in the TRM are a bit vague and I cant work out how I can relate it to the problem I have.

Cheers,

Alan

  • Would this work?

    Read -8bit

    Write-64bit

    E Count-8

    F Count-1

    Source E Index-4

    Source F Index-0

     

     

  • Hi Alan,

    If you are reading the ADC resulting RAM in FIFO mode then there is no need to use address offset mode. You can keep it as fix address mode.  Since ADC provides an address range in FIFO mode to read out the data it will also work to use address offset mode but it is not necessary. But make sure you add 3 to the source starting address because the DMA operates in big endianism mode. If the FIFO data is 0x00000011 and you want to get the 11 then the source address for the FIFO should be 0xFFF7C093.

  • Hi Charles,

    Thanks for the response, could you provide some more details on the other DMA settings?

    Currently I'm just getting all zeros,zeros up until the last byte which has the last ADC result or only the last ADC byte in the first destination address.  

    This is with trying 8 aand 64bit write, frame and block transfer as well as changing between E count 8 F count 1 and E count 1 F count 8.

    Cheers,

    Alan

  • Hi Alan,

      You can use either address offset mode or fixed address mode for the source. The reason is that you are reading from ADEVBUFFER starting at 0xfff7c090-0xfff7c0AF. This is an address range for reading the ADC RAM in FIFO mode. So either fixed address mode or address offset mode should work. They key is that you need to add 3 to the starting source address. In the below two examples, I use the VIM Channel Mapping register starting at 0xfffffe80+3 for simplicity reason since these registers already have some values in it. I didn't try to set up the ADC so that the ADC RAM will have different sampled values. But the idea is the same.

    /*****************************************************************************/

    Method 1: Using Address offset mode.

    /*****************************************************************************/

    dma_config.SADD = 0xfffffe83;

    dma_config.CHCTRL = 0;

    dma_config.FRCNT = 1;

    dma_config.ELCNT = 8;

    dma_config.ELDOFFSET = 0;

    dma_config.ELSOFFSET = 4;

    dma_config.FRDOFFSET = 0 ;

    dma_config.FRSOFFSET = 0;

    dma_config.PORTASGN = 4;

    dma_config.RDSIZE = ACCESS_8_BIT;

    dma_config.WRSIZE = ACCESS_64_BIT;

    dma_config.TTYPE = FRAME_TRANSFER;

    dma_config.ADDMODERD = ADDR_OFFSET;

    dma_config.ADDMODEWR = ADDR_INC1;

    dma_config.AUTOINIT = AUTOINIT_OFF;

     

    /*****************************************************************************/

    Method 2: Using fix address mode.

    /*****************************************************************************/

    dma_config.SADD = 0xfffffe83;

    dma_config.CHCTRL = 0;

    dma_config.FRCNT = 1;

    dma_config.ELCNT = 8;

    dma_config.ELDOFFSET = 0;

    dma_config.ELSOFFSET = 0;

    dma_config.FRDOFFSET = 0 ;

    dma_config.FRSOFFSET = 0;

    dma_config.PORTASGN = 4;

    dma_config.RDSIZE = ACCESS_8_BIT;

    dma_config.WRSIZE = ACCESS_64_BIT;

    dma_config.TTYPE = FRAME_TRANSFER;

    dma_config.ADDMODERD = ADDR_FIXED;

    dma_config.ADDMODEWR = ADDR_INC1;

    dma_config.AUTOINIT = AUTOINIT_OFF;