程序是这样的
void initializeMSP430(void)
{
int8 i = 0;
WDTCTL = WDTPW + WDTHOLD;// Stop watchdog timer to prevent time out reset
//DCOCTL |= DCO2|DCO1|DCO0;
BCSCTL1 |= XT2OFF + XTS + DIVA0 + DIVA1; // CLOCK SOURCE = LFXT1, Aclk = LFXT1/8
BCSCTL2 |= SELM1 + SELS+DIVS0+DIVS1; // MCLK = LFXT1/2 MSCLK = LFXT1/2
BCSCTL3 |= LFXT1S1+LFXT1OF; // LF = 4 - 16 M LFXT1 oscillator fault
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--){;} // Time for flag to set
}while((IFG1 & OFIFG));
}
//--------------------------------------------------
/*------------------------------------------------
Configure the USCI in spi mode
------------------------------------------------*/
void ConfigSPIMode(void)
{
volatile unsigned char i ;
i = 0;
UCB0CTL0 = UCCKPH + UCCKPL + UCMSB + UCMST + UCSYNC ;//+ UCMODE1
UCB0CTL1 = UCSSEL1+UCSWRST; // UCSSEL1+UCSSEL0 UCSI RESET
P2DIR |= BIT2; // SPI CS OUTPUT
P3DIR = 0x1D;
P3OUT = 0x00; // 101101 P3.1 DI P3.2 DO P3.3 SCK P3.4 RX P3.5 TX
P3SEL = 0x3F;
UCB0CTL1 &= ~UCSWRST; // SPI initialize
//UCSI in spi syncronous mode clock phase is 1 clock polarity is 1
//IFG2 = 0x00; // transmit flag
}void SPITransmit(unsigned char Dat)
{
UCB0TXBUF__SPI = Dat;
while(!(IFG2 & UCB0TXIFG));
}
/
void main()
{
init();
do
{
delayms(2);
SPITransmit(0x55);
delayms(2);
}while(1);
}
为什么当我SPI仿真的时候,接收和发送寄存器都会变,但在发送接的时候用示波器,量SIMO,SCK 一直是高电平并不是正常波形 |