进行建议的更改的唯一问题是SPI端口不再输出数据。我需要将值(0xFF、0x04等)获取到SPI1_Exchange。我设置它的第一种方法实际上是在SPI端口上传输数据。新的方法不是:uint8_t uTransmitData、uReceiveData、uTransmitData;uTransmitData0xFF;uReceiveData=NULL;EnableMSD_SS_端口;SPI1_Exchange(&u发送数据,&u接收数据;SPI1_Exchange(&u发送数据,&u发送数据,&uRecei接收数据;uReceieiveReceiveData;UReceiveData;SPI1_交换(&u发送数据,&u发送数据,&;u接收数据&;u接收数据;u接收数据;SPI1_交换(&;SPI1_交换&交换;交换;交换;交换&;u发送发送发送发送数据,&;u发送数据,&;u发送数据数据,SPI1_Exchange(&uTransmitData, &uReceiveData);SPI1_Exchange(&uTransmitData, &uReceiveData);SPI1_Exchange(&uTransmitData, &uReceiveData);SPI1_Exchange(&uTransmitData, &uReceiveData);禁用MSD_SS_Port;uTransmitData=0x04;SPI1_Exchange(&uTransmitData,&uReceiveData);uTransmitData=0x00;SPI1_Exchange(&uTransmitData,&uReceiveData);uTransmitData=0x00;SPI1_Exchange(&uTransmitData,&uReceiveData);uReceiveData;uTransmitData=0x00;SPI1_Exchange(&uTransmitData,&uReceiveData);uTransmitData=0x95;SPI1_Exchange(&uTransmitData,&uReceiveData);uTransmitData=NULL;uReceiveData=0x00;无符号字符测试;而如果(UnvaveDATA!= 0){测试=1;}空隙SPI1a交换(空隙* pTrimeDATA,Valu*PulvEDATA){UIT88T DimyRead=0;UIT88T DimyDeals= 0xFF;//SPI1DimMyDATA;IF(pPrimeDATA=NULL){pPrimeDATA=&;DimyWrand;}(pPurveDATA=null){pPrimvEdATA=和DimyRead;}(SPI1STATLITSP.SPI)TBF=1){}//--------//发送数据//-------SPI1BUFL**((UIT88*T*)pSimultDATA);而(SPI1STATLITS.SpBube=1){}//--------//提取数据//---------*((UIT88*T*)PrimvEDATA)=(UIT88T)(SPI1BUFL);}
以上来自于百度翻译
以下为原文
The only problem with making your suggested changes is that the SPI port no longer outputs data.
I need to get values (0xFF, 0x04, etc.) to SPI1_Exchange.
The first way that I had it setup actually transmits data on the SPI port.
The new way does not:
uint8_t uTransmitData, uReceiveData;
uTransmitData = 0xFF;
uReceiveData = NULL;
EnableMSD_SS_Port;
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
DisableMSD_SS_Port;
uTransmitData = 0x04;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x00;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x00;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x00;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x00;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x95;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = NULL;
uReceiveData = 0x00;
unsigned char test;
while(1)
{
SPI1_Exchange(&uTransmitData, &uReceiveData);
if (uReceiveData != 0)
{ test = 1; }
}
void SPI1_Exchange( void *pTransmitData, void *pReceiveData )
{
uint8_t dummyRead = 0;
uint8_t dummyWrite = 0xFF;//spi1DummyData;
if(pTransmitData == NULL)
{
pTransmitData = &dummyWrite;
}
if(pReceiveData == NULL)
{
pReceiveData = &dummyRead;
}
while( SPI1STATLbits.SPITBF == 1 )
{ }
// ----------------
// sending data
// ----------------
SPI1BUFL = *((uint8_t*)pTransmitData);
while ( SPI1STATLbits.SPIRBE == 1)
{ }
// ----------------
// extracting data
// ----------------
*((uint8_t*)pReceiveData) = (uint8_t)(SPI1BUFL);
}
进行建议的更改的唯一问题是SPI端口不再输出数据。我需要将值(0xFF、0x04等)获取到SPI1_Exchange。我设置它的第一种方法实际上是在SPI端口上传输数据。新的方法不是:uint8_t uTransmitData、uReceiveData、uTransmitData;uTransmitData0xFF;uReceiveData=NULL;EnableMSD_SS_端口;SPI1_Exchange(&u发送数据,&u接收数据;SPI1_Exchange(&u发送数据,&u发送数据,&uRecei接收数据;uReceieiveReceiveData;UReceiveData;SPI1_交换(&u发送数据,&u发送数据,&;u接收数据&;u接收数据;u接收数据;SPI1_交换(&;SPI1_交换&交换;交换;交换;交换&;u发送发送发送发送数据,&;u发送数据,&;u发送数据数据,SPI1_Exchange(&uTransmitData, &uReceiveData);SPI1_Exchange(&uTransmitData, &uReceiveData);SPI1_Exchange(&uTransmitData, &uReceiveData);SPI1_Exchange(&uTransmitData, &uReceiveData);禁用MSD_SS_Port;uTransmitData=0x04;SPI1_Exchange(&uTransmitData,&uReceiveData);uTransmitData=0x00;SPI1_Exchange(&uTransmitData,&uReceiveData);uTransmitData=0x00;SPI1_Exchange(&uTransmitData,&uReceiveData);uReceiveData;uTransmitData=0x00;SPI1_Exchange(&uTransmitData,&uReceiveData);uTransmitData=0x95;SPI1_Exchange(&uTransmitData,&uReceiveData);uTransmitData=NULL;uReceiveData=0x00;无符号字符测试;而如果(UnvaveDATA!= 0){测试=1;}空隙SPI1a交换(空隙* pTrimeDATA,Valu*PulvEDATA){UIT88T DimyRead=0;UIT88T DimyDeals= 0xFF;//SPI1DimMyDATA;IF(pPrimeDATA=NULL){pPrimeDATA=&;DimyWrand;}(pPurveDATA=null){pPrimvEdATA=和DimyRead;}(SPI1STATLITSP.SPI)TBF=1){}//--------//发送数据//-------SPI1BUFL**((UIT88*T*)pSimultDATA);而(SPI1STATLITS.SpBube=1){}//--------//提取数据//---------*((UIT88*T*)PrimvEDATA)=(UIT88T)(SPI1BUFL);}
以上来自于百度翻译
以下为原文
The only problem with making your suggested changes is that the SPI port no longer outputs data.
I need to get values (0xFF, 0x04, etc.) to SPI1_Exchange.
The first way that I had it setup actually transmits data on the SPI port.
The new way does not:
uint8_t uTransmitData, uReceiveData;
uTransmitData = 0xFF;
uReceiveData = NULL;
EnableMSD_SS_Port;
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
SPI1_Exchange(&uTransmitData, &uReceiveData);
DisableMSD_SS_Port;
uTransmitData = 0x04;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x00;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x00;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x00;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x00;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = 0x95;
SPI1_Exchange(&uTransmitData, &uReceiveData);
uTransmitData = NULL;
uReceiveData = 0x00;
unsigned char test;
while(1)
{
SPI1_Exchange(&uTransmitData, &uReceiveData);
if (uReceiveData != 0)
{ test = 1; }
}
void SPI1_Exchange( void *pTransmitData, void *pReceiveData )
{
uint8_t dummyRead = 0;
uint8_t dummyWrite = 0xFF;//spi1DummyData;
if(pTransmitData == NULL)
{
pTransmitData = &dummyWrite;
}
if(pReceiveData == NULL)
{
pReceiveData = &dummyRead;
}
while( SPI1STATLbits.SPITBF == 1 )
{ }
// ----------------
// sending data
// ----------------
SPI1BUFL = *((uint8_t*)pTransmitData);
while ( SPI1STATLbits.SPIRBE == 1)
{ }
// ----------------
// extracting data
// ----------------
*((uint8_t*)pReceiveData) = (uint8_t)(SPI1BUFL);
}
举报