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.

SPI of msp430f2471

Other Parts Discussed in Thread: ADS1298, MSP430F437, MSP430F2471

I have used msp430f437 communicaed with ads1298 via SPI protocal.

Now I want to change msp430f437 to msp430f2471. 

The communication between msp430f2471 and ads1298 have a problem.When I used release mode,the programme can run correctly.But when I use debug mode, I can't receive the correct data from SPI.

This is some of my programme of msp430f2471:

void SPI_Init(void)
{
P3SEL |= 0x0E; // P3.3,2,1 option select
UCB0CTL1 |= UCSWRST;
UCB0CTL0 |= UCMST + UCMSB + UCSYNC;  //3-pin, 8-bit SPI master //
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 = 0x02; //
UCB0BR1 = 0; //
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
}

BYTE ADS1298_Init(void)
{

while(!(IFG2 & UCB0TXIFG)); // // USCI_B0 TX buffer ready?
UCB0TXBUF = 0x20; // starting register address.
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x00; //  the number of registers to read .
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x00; //
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

if ((i & 0x07) == 0x02) // ID
{

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x41; //  the starting of  register address.
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x02; // the number of registers to write 
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x85; //CONFIG1 
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x00; //CONFIG2
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0xDC; //CONFIG3
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x58; //Write to Register WCT1,WCT2
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x01; //number of registers
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x0B; //WCT1
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0xC2; //WCT2
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x45; //Write to Register CHnSET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x07; //number of registers
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x10; //CH1SET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x10; //CH2SET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x10; //CH3SET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x10; //CH4SET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x10; //CH5SET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x10; //CH6SET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x10; //CH7SET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x10; //CH8SET
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x4D; //Write to Register RLD_SENSP
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0x01; //number of registers
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0xFF;
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;

while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = 0xFF;
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;


SPI_CONVERT_START();
while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = RDATAC; // Put the Device in RDATAC Mode
while (!(IFG2 & UCB0RXIFG));
i = UCB0RXBUF;
if (i == 0)
_NOP();
return 1;
}
else
return 0;

}