1
votes

I am working on MSP430 Series Controller and I have a buffer to be sent on UART via DMA.

I am pasting my DMA configuration and Code snippet for more information.

DMACTL0 = DMA0TSEL__UCA0TXIFG;
DMA0SA  = &buff;
DMA0DA  = &UCA0TXBUF; 
DMA0SZ  = 64;                      // Block size in bytes
DMA0CTL = DMADT_1 | DMASBDB| DMASRCINCR_1 | DMAIE| DMALEVEL_L; // Rpt, inc
DMA0CTL|= DMAEN;

I am filling data as below.

   char buff[64];
   buff[0] = 0x64;
   buff[1] = 0x23;
   buff[2] = 0x65;
   buff[3] = 0x31;

When I initiate DMA transfer , The buffer got transfer but When I check on terminal , Its shows only the first value '0x64', Not other value.I am doing block transfer , so whole block should be transfered when dma initiated. And in Interrupt routing i am reseting the dma flag.

My interrupt Handler.

 __interrupt void DMA_VECTOR_ISR(void)
 {
     DMA0CTL &= ~DMAIFG;
     DMA_Doneflag = 1;
 }

this DMA_Doneflag I have took as boolean volatile and that is reset when tx is done.

1

1 Answers

1
votes

A block transfer indeed copies the whole block; it is the equivalent of the following:

while (!(UCA0IFG & UCTXIFG)) {}  // wait for trigger
for (i = 0; i < 64; i++)
    UCA0TXBUF = buf[i];

This is not what you actually want. You need to wait for the trigger before each single byte:

for (i = 0; i < 64; i++) {
    while (!(UCA0IFG & UCTXIFG)) {}
    UCA0TXBUF = buf[i];
}

This can be done with the repeated single transfer mode (DMADT_4).

And you need DMASRCINCR_3 to actually go through the buffer.