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.

MSP430F5341的SPI配置问题,为什么用示波器看不到时钟信号?



spi初始化程序如下,选用B0组,4线制,我这样配置有问题吗?希望大神点拨一下

 

 while(!(P3IN&0x04));                              // 读取时钟端,p3.2,If clock sig from mstr stays low,说明它未在spi模式    

 UCB0CTL1 |= UCSWRST;                     // **Put state machine in reset**,软件复位使能,时钟选为SMCLK。                  

 P3SEL |= BIT0+BIT1+BIT2;                   // P3.0,1,2,选为外围模式。  

 P2SEL |= BIT7;                                      // P2.7 option select,选择为外围设备通信模式,片选

 UCB0CTL1 |= UCSSEL__SMCLK;                              // 时钟选为SMCLK。  

 UCB0CTL0 |= UCCKPL+UCMSB+UCMST+UCMODE1+UCSYNC;          // mode1=0x40,4-pin, 8-bit SPI master,片选为低电平有效。                                                   // UCSYNC=1同步模式使能,UCCKPL=1下降沿触发,UCMST=1主模式,UCMSB=1MSB先高后低八位。                                                           // Clock polarity high, MSB    

 UCB0BR0 = 1;                              // /2,相当于2分频,BR0控制低8,BR1控制高8位  

 UCB0BR1 = 0;                              //  

 UCB0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**

 P2OUT &= ~BIT7;                             // 把p2.7脚置为低电平,使能