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.

CCS/MSP430F5659: MSP430F5659 SPI COMMUNICATION

Part Number: MSP430F5659
Other Parts Discussed in Thread: MSP430WARE

Tool/software: Code Composer Studio

Dear sir/Madam,

i am using MSP430F5659 controller and i am geeting a problem on SPI Communication.

I have to send 16 bit data through SPI, Which is not possible for one write operation so to write the 16 bit data we have to write 2 operations that 8 bit MSB and 8 BIT LSB.

so kindly check my code and help me whether i am wrong or right.

Here i am attaching the code of spi communication

void spi_initial()
{
P9SEL |= (SPISOMI+SPISIMO+SPICLK);
UCB2CTL1 |= UCSWRST;
UCB2CTL1 |= UCSSEL_2;
UCB2CTL0 |= ( UCMSB +UCMST + UCSYNC + UCCKPH + UCMODE_1);
UCB2CTL1 &= ~UCSWRST;
}
void send( int data,int i)
{
int l;
__disable_interrupt();
l=data;
l=l>>8;
while(i){
while(!( UCB2IFG & UCTXIFG));
UCB2TXBUF = l;
l=data;
i--;
}
while(UCB2STAT & UCBUSY);
__enable_interrupt();
}

send function are:

P9OUT&=~BIT0;
send(0x2128,2);
P9OUT|=BIT0;
__delay_cycles(100);
P9OUT&=~BIT0;
send(0x4D31,2);
P9OUT|=BIT0;
__delay_cycles(100);
P9OUT&=~BIT0;
send(0x40DD,2);
P9OUT|=BIT0;
__delay_cycles(100);
P9OUT&=~BIT0;
send(0xC000,2);
P9OUT|=BIT0;
__delay_cycles(100);
P9OUT&=~BIT0;
send(0x2028,2);
P9OUT|=BIT0;
}