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.

msp430f249 SPI ptoteus

Other Parts Discussed in Thread: MSP430F249

使用IAR 开发,在proteus中运行,

SPI   手册里说有SPI_A0,SPI_A1,SPI_B0,SPI_B1  4个,但是我实验,只有SPI_B0成功了,其余3个都不能正常输出CLK,MOSI。

这个是SPI_A0<是从官网里范例包获得的。

#if 0
//SPI 选择 UCA0 发不出数据,不知道为什么
P3DIR |= 0x11;
P3SEL |= 0x11; // P3.0,4 USCI_A0 option select
UCA0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 |= 0x0A;
UCA0BR1 = 0;
//UCA0MCTL = 0;
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**


Data = 0x0F0; // Load inital data
while(1)
{
UCA0TXBUF = Data; // Byte to SPI TXBUF
Data++; // Increment Data value - Set BREAKPOINT here
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
SET_LE;
CLR_LE;
for(i = 0xFF; i > 0; i--); // Delay

}
#endif

这个是SPI_B0,在网上获得的,可以正常运行

#if 1

P3SEL |= 0x0E; // P3.3,2,1 USCI_B0 option select,注意管脚配置
P3DIR |= 0x01; // P3.0 output direction
UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI mstr, MSB 1st
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 = 0x01;
UCB0BR1 = 0;
UCB0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**


Data = 0x00; // Load inital data
while(1)
{
UCB0TXBUF = Data; // Byte to SPI TXBUF
Data++; // Increment Data value - Set BREAKPOINT here
while (!(IFG2 & UCB0TXIFG)); // USCI_A0 TX buffer ready?
SET_LE;
CLR_LE;
for(i = 0xFF; i > 0; i--); // Delay

}

#endif