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.
void SPI_MISO_Inint()
{
P3SEL |= BIT0+BIT3+BIT5; // P3.5,4,0 option select
UCA0CTL 1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL0 |= UCSYNC+UCCKPH+UCMSB+UCMODE_1; //同步模式,第一个上升沿捕获数据,MSB优先,四线SPI,UC0STE=1从机使能
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // 使能接受中断
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
{
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
received_data[data_index++]=UCA0RXBUF;
if(data_index==128)
data_index=0;
}
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
输入的波形如同所示:
但是为什么没有接收值呢?(received_data 中的值全是0);
我想用msp430F5438A只做从机,去捕获外部的数据。
希望工程师们能够解答我的问题,谢谢!
你的管脚都配置错了
P3SEL |= BIT0 + BIT3 + BIT5; 这句 更改成P3SEL |= BIT0+BIT4+BIT5;
MSP430F5438A的P3.0. P3.4 P3.5 被分配为SPI的 CLK, MOSI, 和MISO, 你的P3.4都没配成SPI口,咋个能接收到数据嘛。
建议基于TI提供的code example开发,有助于加快进度。可单独下载code example, 也可用MSP430Ware, 装了CCS的话,此路径下就有。
C:\ti\CCS5_4_0\ccsv5\ccs_base\msp430\msp430ware_1_40_00_26\examples\devices\5xx_6xx