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.

Problem with 4 Pin SPI



Using 430F1481 and try to use SPI 4 pin.
First i tried with the example code with 3 pin SPI and it works but
when i change to 4 pins the SPI goes totaly dead.

 

 

#include <msp430x14x.h>
#include <string.h>

#define SCK_HIGH P5OUT |=0x08       //clock   out
#define SCK_LOW P5OUT &=~0x08
   
#define SIN_HIGH P5OUT |=0x02       //data  out
#define SIN_LOW P5OUT &=~0x02
#define sout (P5IN & 0x04)/(0x04)   // data in
#define CS_HIGH P4OUT |=0x08        // chip select high
#define CS_LOW P4OUT &=~0x08        // chip select low

void spi_init();


void main()
{
  unsigned int i=0;
  unsigned int Data=0;
  Data =0x0FF;
   
  spi_init(); 
  while(1)
  {
   Data++;
   while (!(IFG2 & UTXIFG1));
   TXBUF1 = Data;
   for(i = 0xEFFF; i > 0; i--);
  }
}

void spi_init()
{
  P5SEL |=0x0A;
  P5DIR |= 0x0B;                            //Reset Slave
  P5OUT &= ~0x01;
 
  P4DIR |=0x08;
  P4OUT |=0x00;
 
  UCTL1 = CHAR + SYNC + MM + SWRST;         // 8-bit, SPI, Master
  UTCTL1 = CKPH + SSEL1;               // Polarity, SMCLK, 3-wire
 
  UBR01 = 0x02;                             // SPICLK = SMCLK/2
  UBR11 = 0x00;
  UMCTL1 = 0x00;
  ME2 |= USPIE1;                            // Module enable
  UCTL1 &= ~SWRST;                          // SPI enable
  IE2 |= URXIE1 + UTXIE1;                   // RX and TX interrupt enable
}  

 

rishi

  • HI singal,

    1)check on what modes(Mode0-Mode3) ur slave is working

    2)  #define SCK_HIGH P5OUT |=0x08       //clock   out
         #define SCK_LOW P5OUT &=~0x08

    r u using bit-banking mode?

    3) P5SEL |=0x0A;
      P5DIR |= 0x0B;                            //Reset Slave
      P5OUT &= ~0x01;

    what this selecting meant for?

    4)

    while (!(IFG2 & UTXIFG1));
       TXBUF1 = Data;

    inverse tha above code and check i.e.,

     TXBUF1 = Data;

    while (!(IFG2 & UTXIFG1));
      

**Attention** This is a public forum