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.

About DMA transfer size

Other Parts Discussed in Thread: MSP430F5438A

Hi,

I am using MSP-EXP430F5438 experiment board with MSP430F5438A. I want to transfer data from ADC12MEM0 to a buffer. I looked into the sample project of User Experience and don't understand how the transfer size came. Here is the code which is in audio.c:

         __data16_write_addr((unsigned long)&DMA0DA & 0xffff, (unsigned long)AUDIO_MEM_START[i]); 

 

          DMA0SZ = AUDIO_MEM_START[i + 1] - AUDIO_MEM_START[i] - 1; 

 

            record();

 

            if (DMA0SZ != AUDIO_MEM_START[i + 1] - AUDIO_MEM_START[i] - 1)   

            {

                lastAudioByte = AUDIO_MEM_START[i + 1] - DMA0SZ;

                break;

            }

            else lastAudioByte = AUDIO_MEM_START[i + 1] - 1;

 

Here I notice that the transfer size is calculated by "AUDIO_MEM_START[i + 1] - AUDIO_MEM_START[i] - 1". Why there is a "-1". If I only want to transfer one unsigned long, then what should the size is?

Thanks.

Shan

  • Hi Shan,

    The DMA controller can transfer from byte sources (like UART) or from word sources (like ADC).  That's it.  To fill a 32-bit (unsigned long) buffer from a byte source, you need 4 transfers, so the size is 4.  To fill a 32-bit (unsigned long) buffer from a word source, you need 2 transfers, so the size is 2.

    It's not clear from your post why the sample code uses "- 1", so you would have to learn about their code and how it uses the data buffers and the start addresses stored in that array.  Maybe at the start address they store a length or some other piece of data and then comes the audio samples up to the next start address.  Who knows.

    Jeff

**Attention** This is a public forum