问题遇到的现象和发生背景
使用mcal的spi与旋变芯片进行通信,无法获得旋变芯片的spi反馈
遇到的现象和发生背景,请写出第一个错误信息
用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
void Ex_Spi3_MasterSequenceEndNotification(void)
{
Spi_ReadIB(SpiConf_SpiChannel_SpiChannel_1, Ex_Spi3_MasterRxDataBuffer);
Ex_Spi_CheckRxResult(Ex_Spi3_MasterRxDataBuffer);
}
void SPI_ReadWriteByte()
{
//Spi_SetupEB(SpiConf_SpiChannel_SpiChannel_1, Ex_Spi3_MasterTxDataBuffer, Ex_Spi3_MasterRxDataBuffer, 100U);
Spi_WriteIB(SpiConf_SpiChannel_SpiChannel_1, Ex_Spi3_MasterTxDataBuffer);
Spi_AsyncTransmit(SpiConf_SpiSequence_Spi3Sequence_Master);
if(check_finish==0){
check_sequence_finish();
}
CS_L();
Ex_Spi3_MasterSequenceEndNotification();
CS_H();
}
void SC2161_WRITE(uint8 data) // 无论数据还是地址 模拟时序发送
{
CS_L();
for (Index = 0U; Index < EX_SPI_CHANNEL_LENGTH; Index++)
{
Ex_Spi3_MasterTxDataBuffer[Index] = data;
SPI_ReadWriteByte();
}
CS_H();
}
uint8 wr(uint8 DAT)
{
uint8 temp=0;
uint8 temp2=0;
uint8 a=0;
CS_H();
SAM_H();
//Delay(30);
SAM_L();
CS_L();
temp=DAT;
//SPI1_ReadWriteByte(temp2);
Spi_ReadIB(SpiConf_SpiChannel_SpiChannel_1, Ex_Spi3_MasterRxDataBuffer);
for (Index = 0U; Index < EX_SPI_CHANNEL_LENGTH; Index++)
{
if( (uint8*)temp == &(Ex_Spi3_MasterRxDataBuffer[Index]))
{
temp2=Ex_Spi3_MasterRxDataBuffer[Index];
}
// *temp = Ex_Spi3_MasterRxDataBuffer[Index];
}
CS_H();
//Delay(30);
CS_L();
//temp=SPI1_ReadWriteByte(temp2);
//Spi_ReadIB(SpiConf_SpiChannel_SpiChannel_1, Ex_Spi3_MasterRxDataBuffer);
CS_H();
return temp2;
}
运行结果及详细报错内容
wr方法中获取的spi返回结果一直是0
我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%
如何获得旋变指定寄存器的值,通过spi通信