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.

MSP430G 系列USI 中SPI 传输16位数据

有没有大佬帮忙看看,我传输16位数据,这样写对吗?

void Spi_Init()
{
USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE; // Port, SPI master
USICTL1 |= USIIE; // USI计数器中断启用
USICKCTL = USIDIV_4 + USISSEL_2; // /16 SMCLK
USICTL0 &= ~USISWRST; // USI released for operation
USISR = 0xfff0; // init装载数据
USICNT |= USI16B; //启用16位寄存器
USICNT |= 16; // init装载计数
}

uint Spi_RW(uint Send_Val)
{
uint Rec_Val;
USISR = Send_Val;
while(!(USIIFG & USICTL1)); //等待数据发送完成
USICTL1 &= ~USIIFG;
USICNT = 16;
while(!(USIIFG & USICTL1)); //等待数据发送完成
USICNT = 16;
Rec_Val = USISR;
USICTL1 &= ~USIIFG;
return (Rec_Val);
}

x 出现错误。请重试或与管理员联系。