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 in Transmitting Data in SPI COmmunication.



hi,

i have  a Problem while sending the data in SPI -  SO PIn.

 

please see this code, i geeting always a 'U' charater in CRO.

 

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

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

void cs_delay(void);
void serial_send(unsigned char Char_Out);
void UART0_Init(void);
void spi_init();

void testspi(void);

void main()
{
  WDTCTL = WDTPW + WDTHOLD;
 
 spi_init();
 while(1)
 {
  TXBUF1 = 'W';
 }  
}

void spi_init()
{
  P5SEL |= 0x0E;                            // P5.1,2,3 SPI option select
  P5OUT &= ~0x01;
  P5DIR |= 0x01;                            //Reset Slave
 
  P5DIR &= ~0x01;
 // P5DIR |= 0x0C;                            //Reset Slave
 
  P4DIR |=0x08;
  P4OUT |=0x00;

 
  UCTL1 = CHAR + SYNC + MM + SWRST;         // 8-bit, SPI, Master
  UTCTL1 =  CKPL + SSEL1 + STC;              // 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
 
}  




void UART0_Init(void)
{
 
  volatile unsigned int i;
  P3SEL |= 0x30;                            // P3.4,5 = USART0 TXD/RXD

  BCSCTL1 &= ~XT2OFF;                       // XT2on

  BCSCTL2 |= SELM_2 + SELS;                 // MCLK = SMCLK = XT2 (safe)
  ME1 |= UTXE0 + URXE0;                     // Enable USART0 TXD/RXD
  UCTL0 |= CHAR;                            // 8-bit character
  UTCTL0 |= SSEL1;                          // UCLK = SMCLK
  UBR00 = 0x41;   //9600                    // 8MHz 115200
  UBR10 = 0x03;   //9600                    // 8MHz 115200
  UMCTL0 = 0x09;                            // 8MHz 115200 modulation
  UCTL0 &= ~SWRST;                          // Initialize USART state machine
}

 

 

here i  am sending 'W' data continiously, but i get 'U' response in CRO continusly.

 

 

Regards

rishi

 

 

 

 

**Attention** This is a public forum