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.

MSP430F1611: MSP430F1611 SPI problem

Part Number: MSP430F1611

I am using MSP430F1611, and I want to perform SPI communication between MSP430F1611(Master) and FPGA(Slave), I can send data successfully from MSP430F1611 to FPGA and get miso data in U0RXBUF and RXBUF0, now problem is how to store data from ( U0RXBUF and RXBUF0) in any other variable, please help me to solve this problem.

Thanks

Regard.

Code:

#include <msp430.h>
char  MST_Data = 0x4F;
unsigned char msd,msd1,msd2;

unsigned int j;
unsigned int i;
int main(void)
{
 

   WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
   P3DIR =0x001;
  
  P3SEL = 0x00E;                            // Setup P3 for SPI mode
 
  
  
  
  // U0CTL =         (0x0070u)     /* USART 0 Control */
  // CHAR  =         (0x10)        /* Data 0:7-bits / 1:8-bits */
  // SYNC  =         (0x04)        /* UART / SPI mode */
  // MM    =         (0x02)        /* Master Mode off/on */
  
  U0CTL = CHAR + SYNC + MM + SWRST;         // 8-bit, SPI, Master
  
  
  U0TCTL = CKPH + SSEL1 + STC;              // Polarity, SMCLK, 3-wire
  
  
  // U0BR0  =      (0x0074u)  /* USART 0 Baud Rate 0 */
 // U0BR0 = 0x064;                            // SPICLK = SMCLK/2
  
  // U0BR1  =      (0x0075u)  /* USART 0 Baud Rate 1 */
  U0BR1 = 0x000;
  
 // UMCTL0  =        U0MCTL    /* USART 0 Modulation Control */  reg name
  U0MCTL = 0x000;

  
  
// ME1 =      (0x0004u)  /* Module Enable 1 */
  ME1 = USPIE0;                             // Module enable
  U0CTL &= ~SWRST;                          // SPI enable
  
    IE1 |= URXIE0;                            // Recieve interrupt enable
  __enable_interrupt();                     // Enable interrupts

  //TXBUF0 = 0x00;
  msd = RXBUF0;
  msd1 = U0RXBUF;
  i = 50000;                                // Delay
  do (i--);
  while (i != 0);
msd = RXBUF0;

  msd1 = U0RXBUF;
  {msd = RXBUF0;
  msd1 = U0RXBUF;
 
   TXBUF0 = MST_Data;                      // Transmit first character
    LPM0;                                   // CPU off
 
    }
   msd = RXBUF0;
  msd1 = U0RXBUF;

    
    
} // End Main

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USART0RX_VECTOR

__interrupt void SPI0_rx (void)
#elif defined(__GNUC__)

void __attribute__ ((interrupt(USART0RX_VECTOR))) SPI0_rx (void)
#else
#error Compiler not supported!
#endif
{

    
    j = 5000;                                // Delay
  do (j--);
  while (j != 0);
  
TXBUF0 = MST_Data;
 

/*
  
     j = 10000;                                // Delay
  do (j--);
  while (j != 0);
  
  TXBUF0 =0x34;
  
     j = 10000;                                // Delay
  do (j--);
  while (j != 0);
  
  TXBUF0 =0x56;
  
  
     j = 10000;                                // Delay
  do (j--);
  while (j != 0);
  
  TXBUF0 =0x78;
  
  
     j = 10000;                                // Delay
  do (j--);
  while (j != 0);
  
  TXBUF0 =0x9A;

  
  */
  
  
  
  //TXBUF0 =0xab;

  
 
 // TXBUF0 =0xbb;
  
  //P3OUT =0x00;
}

  • Hello Rizwan,

    for debugging SPI issues, please see the following app note.

    http://www.ti.com/lit/slaa734

    For a examples of SPI communication for this device, please see the following.

    dev.ti.com/.../
  •  I have only one small issue,  that how to get data from ( U0RXBUF and RXBUF0) and store in other variable, e.g I am using variable msd and use msd = U0RXBUF or mad = RXBUF0 but value of msd is zero.

    please tell me how to solve this...?

  • Hello Rizwan,

    Please check the SPI examples I linked to earlier. they show a similar situation. all you have to is when you get a receive interrupt, is to assign your variable the value of the RXBUFF. In the screenshot above, you haven't run your code yet, thus nothing will be in your variable. Also, check your optimization levels and turn them off as if you just take data out of the buffer to a variable, and never use the variable for anything, the compiler my optimize out this code. 

    Pseudo-code

    receive_bufferISR
    (
    
    	var = rxbuff;
    	
    }

**Attention** This is a public forum