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.

MSP430F5328 spi 自发自收可以,外接EEPROM不能读写(程序在其他CPU可以)

与模拟SPI不同的就这两个函数:

bool SPI_WriteData(unsigned char val)
{
     unsigned char temp;
     UCB1TXBUF=val;
     while (!(UCB1IFG&UCTXIFG));
     while (!(UCB1IFG&UCRXIFG));
     temp=UCB1RXBUF;
     return TRUE;
}

unsigned char SPI_ReadData(void)
{
   
     unsigned char val;
     UCB1TXBUF=0x00;
     while (!(UCB1IFG&UCTXIFG));
     while (!(UCB1IFG&UCRXIFG));
     val=UCB1RXBUF;
     return val;

}

spi初始化函数:

void SPIFlash_Init(void)
{
   //P4.3,2,1 option select
     unsigned int temp;
     P4DIR |=BIT0;//;//P4.0 P4.1 P4.3 output
     P4OUT|=BIT0;//CS=H
     UCB1CTL1 |=UCSWRST;//SPI enable
     UCB1CTL0 =0X29;
     UCB1CTL1 &= ~(UCSSEL_3);   
     UCB1CTL1 |=0X40;
     UCB1STAT &=0x01;
     UCB1BR0 =0x04;
     UCB1BR1 =0x00;
     P4SEL |=(BIT1+BIT2+BIT3);//04.1 p4.2 p4.3 SCK SI SO
     P4DIR |=(BIT1+BIT3);//P4.0 P4.1 P4.3 output
     P4DIR &=~BIT2;   //p4.2 input
     UCB1CTL1 &=~UCSWRST;//SPI enable
     __delay_cycles(100);
    
}

郁闷。430啊,问ti的技术,不尿。郁闷