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.

continuously send by SPI with DMA

Other Parts Discussed in Thread: MSP430F5419A

Using msp430f5419a with CCSv5.1

I am trying to send 1 byte continuously by SPI with DMA.

The idea is to send 1 byte and get it back in DMA channel interrupt handler.

Have 2 problems:

1. 2nd time send not happened

2. Accepted byte has wrong value

#include "msp430x54xA.h"
 
char TxString = 0x01;
char RxString = 0x00;
 
void main(void)
{
  WDTCTL = WDTPW+WDTHOLD;
 
  P1OUT |= 0x02;
  P1DIR |= 0x03;                            // P1.0 = Output
  P3SEL |= 0x31;                            // P3.0,4,5 = USCI_A0 SPI Option
 
  UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
  UCA0CTL0 = UCMST+UCSYNC+UCCKPL+UCMSB;     // 3-pin, 8-bit SPI master
                                            // Clock polarity high, MSB
  UCA0CTL1 = UCSSEL_2;                      // SMCLK
  UCA0BR0 = 0x02;                           // /2
  UCA0BR1 = 0x00;                           //
  UCA0MCTL = 0x00;                          // No modulation
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
 
  P1OUT &= ~0x02;
  P1OUT |= 0x02;
 
  DMACTL0 = DMA1TSEL_16+DMA0TSEL_17;        // DMA0 - UCA0TXIFG
                                            // DMA1 - UCA0RXIFG
  // Setup DMA0
  __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &TxString);
                                            // Source block address
  __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA0TXBUF);
                                            // Destination single address
  DMA0SZ = 1;                               // Block size
  DMA0CTL = DMASRCINCR_3+DMASBDB+DMALEVEL+DMADT_4;  // inc src
 
  // Setup DMA1
  __data16_write_addr((unsigned short) &DMA1SA,(unsigned long) &UCA0RXBUF);
                                            // Source block address
  __data16_write_addr((unsigned short) &DMA1DA,(unsigned long) &RxString);
                                            // Destination single address
  DMA1CTL &= ~DMAIFG;
  DMA1SZ = 1;                               // Block size
  DMA1CTL = DMADSTINCR_3+DMASBDB+DMALEVEL+DMAIE;  // inc dst
 
  DMA1CTL |= DMAEN;
  DMA0CTL |= DMAEN;
 
  __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ interrupts
  __no_operation();                         // Required only for debugger
}
 
#pragma vector=DMA_VECTOR
__interrupt void DMA_ISR(void)
{
  switch(__even_in_range(DMAIV,16))
  {
    case 0: break;
    case 2:                                 // DMA0IFG = DMA Channel 0
        P1OUT |= 0x01;
        __delay_cycles(24000);
        P1OUT &= ~0x01;
      break;
    case 4:                                 // DMA1IFG = DMA Channel 1
        if (RxString == TxString) {
            P1OUT |= 0x01;
            __delay_cycles(48000);
            P1OUT &= ~0x01;
        }
      break;
    case 6: break;                          // DMA2IFG = DMA Channel 2
    case 8: break;                          // DMA3IFG = DMA Channel 3
    case 10: break;                         // DMA4IFG = DMA Channel 4
    case 12: break;                         // DMA5IFG = DMA Channel 5
    case 14: break;                         // DMA6IFG = DMA Channel 6
    case 16: break;                         // DMA7IFG = DMA Channel 7
    default: break;
  }
}

**Attention** This is a public forum