TI的工程师:
你好!我用的是cc430f5137,准备用UCB0做为硬件SPI直接连传感器,程序如下:
P1OUT &= ~ BIT7; //cs
PMAPPWD = 0x02D52;
P1MAP2 = PM_UCB0SOMI; // Map UCA0SOMI output to P2.2 P1MAP3 = PM_UCB0SIMO; // Map UCA0SIMO output to P2.0 P1MAP4 = PM_UCB0CLK; // Map UCA0CLK output to P2.4 PMAPPWD = 0; P1SEL |= BIT2 +BIT3 +BIT4; //选择spiio
P1DIR |= BIT3 +BIT4 ; //输出
UCB0CTL1 |= UCSWRST; // **Put state machine in reset**
UCB0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB;//+UCCKPH; // 3-pin, 8-bit SPI master
UCB0CTL1 |= UCSSEL_1; //aclk UCB0BR0 |=0x02;
UCB0BR1 |=0x00;
// UCA0MCTL |=0x4A;
UCB0CTL1 &= ~UCSWRST;
while(1)
{
读数据
}
现在的问题是,spi都没通,帮忙看下spi设置有问题?还是?谢谢了
Viki Shi:
请参考官网的代码:http://www.ti.com/cn/lit/zip/slac526
Bruce Wei:
请下载msp430ware,里面有所有的例程
http://www.ti.com/tool/msp430ware