你好,我正在使用SPI在无线ZigBee模块(从机)和PIC18F420(主机)之间进行
通信。这里是SPI部分:/*SS_Set();(len--){unsigned char TempVar;TempVar=SSPBUF;.//Clears BFPIR1bits.SSPIF=0;.//Clear inter.flagSSPCON1bits.WCOL=0;SSPBUF=*pBuf;.//启动SPI bu轮到你了!(PIR1bits.SSPIF);..//等待,直到“BF”位被设置*pBuf+=SSPBUF;}SS_Clr();..//Slave Clear(Ac
tive.)*/如果接收到奇值ascii数据,SPI代码似乎挂起。例如:无线模块(1)=A.Module(2)+PIC(Master)=B当A向B发送一组数据(“AAA”或“0x41,0x41,0x41”)时,B中实现的代码在接收到两到三组之后似乎挂起。没有任何问题。只有当发送一组奇数值ASCII数据时,它才会挂起。
以上来自于百度翻译
以下为原文
Hello,
I'm communicating between a wireless zigbee module (Slave) and pic18f4520(master) using SPI. Here is the SPI part:
/*
SS_Set(); //Slave Set (Active Low)
while (len--)
{
unsigned char TempVar;
TempVar = SSPBUF; // Clears BF
PIR1bits.SSPIF = 0; // Clear interrupt flag
SSPCON1bits.WCOL = 0;
SSPBUF = *pBuf; // initiate SPI bus cycle
while(!PIR1bits.SSPIF); // wait until 'BF' bit is set
*pBuf++ = SSPBUF;
}
SS_Clr(); //Slave Clear (Active Low)
*/
The SPI code seems to hang if an odd-value ascii data is received. For example:
Wireless Module (1) = A
Wireless Module(2)+PIC(Master) = B
When A sends a set of data ("AAA" or "0x41,0x41,0x41") to B, the code which is implemented in B seems to hang after receiving two or three sets.
When A sends a set of data ("BBB" or "0x42,0x42,0x42") to B, it receives continuously without any issues. It only hangs if A sends a set of odd-value ascii data.