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不用中断发送和接收怎么不行啊



MSPF430F5328 用p4.1 p4.2 p4.3 SCK SI SO;用查询发送和接收,为什么不行呢?代码如下:

void SPIFlash_Init(void)
{
   //P4.3,2,1 option select
     P4OUT|=BIT0;//CS=H
     P4DIR |=BIT0;//|(1<<BIT1)|(1<<BIT3);//P4.0 P4.1 P4.3 output
   
    //P4DIR &=~(1<<BIT2);   //p4.2 input
     P4SEL |=(1<<BIT1)|(1<<BIT2)|(1<<BIT3);//04.1 p4.2 p4.3 SCK SI SO
  
   
   
    UCB1CTL1 |=UCSWRST;//SPI enable
    UCB1CTL0=0X29;//同步
    UCB1CTL1 |=SPI_CLOCKSOURCE_SMCLK;
   
    UCB1BR0 =0X02;                     
    UCB1BR1 =0; //0分频
    //UCB1IE=0X03;
    UCB1CTL1 &=~UCSWRST;//SPI enable
   
     __delay_cycles(100);

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

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

}

请教高手,问题出在哪里?谢谢!