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.

!! msp430f6779 DMA uart transmit usage methode !!



Hi friends,

My question is aboutusing  DMA for usart transmit buffer. I checked some examples for that. Some of them use timer  as DMA trigger, some of them use software trigger. My question is I have an idea about DMA usage and I dont even know if it is exist or not. Can you please tell me how I can aply this idea on DMA. Here is the idea:

For example I prepared a buffer for send on uart. I have a function called "send_uart" my program get in this function and make a software trigger for DMA. Please assume I already inited my DMA cahennel number, addresses ..vb. In my "send uart"  function, I set size of buffer and I give a software trigger( DMA0CTL |= DMAREQ) for DMA. And the program counter get out of the function and DMA all handle about the sending buffer.  

I tried this methode but I failed cos I think DMA writes datas on TXBUF of my UART event it is not ready for it. I can not send all of my datas just some.

Can anyone tell me what I should to do for this methode.? Notice that, I dont wanna use any timer for trig my DMA.

Thanks.

 

  • Baycan,

    the trigger for the DMA should be TXIFG. You have an array with your data and you let point the source address to that array + 1, setting the DMA to increment the source address. Destination is the TX buffer, of course. The byte count is the array size -1. Now enable the DMA - the trigger is edge sensitive, so an already set TXIFG (it should be set because the TX buffer is empty at the moment) will not trigger the DMA, the IFG has to switch from 0->1. You can now throw your first byte of the array into the TX buffer which will set the TXIFG to 0 and immediately to 1 again which will now trigger the DMA. Then everything runs in the background until the DMA has sent all bytes.

    Dennis
  • Dennis you are the man :)

    Thanks for your quick and helpfull reply. I tried it and it works. Here is the code. I hope It helps another people who search this topic. It s simple but very effective.

    DMACTL0 = DMA0TSEL_17;// Software Trigger


    __data16_write_addr((unsigned short) &DMA0SA, (unsigned long) buffer);
    // Source block address
    __data16_write_addr((unsigned short) &DMA0DA, (unsigned long) UCA0TXBUF_);

    DMA0SZ = length; // Block size
    DMA0CTL = DMADT_0 + DMASRCINCR_3 + DMASBDB; // inc src, enable

    DMA0CTL |= DMAEN;

    UCA0IFG &= ~UCTXIFG;
    UCA0IFG |= UCTXIFG;

**Attention** This is a public forum