我用MPS430G2333 的SPI接口连接外部芯片,发现在SPI读的时候没有时钟信号CLK输出的?.
P1.4:STE P1.5:CLK P1.6:SOMI P1.7:SIMO
的设置如下:
P1SEL |= BIT5+BIT6+BIT7; // Set SPI peripheral bits
P1SEL2 |= BIT5+BIT6+BIT7;
P1DIR |= BIT4+BIT5+BIT7; // STE, SCLK, and DOUT as output
P1DIR &= ~BIT6; // Din as input
P1OUT |=BIT4; // Set STE high
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 |= UCMSB+UCCKPH+UCMST+UCSYNC; // [b0] 1 - Synchronous mode
// [b2-1] 00- 3-pin SPI
// [b3] 1 - Master mode
// [b4] 0 - 8-bit data
// [b5] 1 - MSB first
// [b6] 0 - Clock polarity high.
// [b7] 1 - Clock phase - Data is captured on the first UCLK edge and changed on the following edge.
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 = 0xFF; // 16 MHz
UCB0BR1 = 0; //
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
UC0IE |= UCB0RXIE;
UC0IFG &= ~UCB0RXIFG;
我用SPI发数据是这样的:
UCB0TXBUF = reg_address;
while ( (UCB0STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
这样CLK 和SMIO都有正确的脉冲输出哦!
但我读SPI,比如这样:
S_buf = UCB0RXBUF;
就根本没有CLK的脉冲时钟输出啊?读不到数据.是我那里方法不对吗?
谢谢!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>