微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 硬件电路设计 > TI模拟硬件电路设计 > AFE4490没有数据返回

AFE4490没有数据返回

时间:10-02 整理:3721RD 点击:

请教一下大家,用的是STM32F103ZET6控制芯片,使用SPI3口,测试有SPI信号有波形,但是AFE4490没有数据返回,读到的一直是0。程序如下:

//读写SPI总线
u8 SPI3_ReadWriteByte(u8 TxData)
{
u8 retry=0;
while (SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_TXE) == RESET) //检查指定的SPI标志位设置与否:发送缓存空标志位
{
retry++;
if(retry>200)return 0;
}
SPI_I2S_SendData(SPI3, TxData); //通过外设SPIx发送一个数据
retry=0;

while (SPI_I2S_GetFlagStatus(SPI3, SPI_I2S_FLAG_RXNE) == RESET) //检查指定的SPI标志位设置与否:接受缓存非空标志位
{
retry++;
if(retry>200)return 0;
}
return SPI_I2S_ReceiveData(SPI3); //返回通过SPIx最近接收的数据
}

//写AFE数据
void AFE4490_WriteData(u32 data, u8 addr)
{
u8 temp;
AFE4490_CS_ENABLE();
delay_us(10);

//写数据
SPI3_ReadWriteByte(addr);//写地址
temp=data>>16;
SPI3_ReadWriteByte(temp);//写高8位
temp=data>>8;
SPI3_ReadWriteByte(temp);//写中8位
SPI3_ReadWriteByte(data);//写低8位
delay_us(10);
AFE4490_CS_DISABLE();
}

//读取AFE数据
u32 AFE4490_ReadData(u8 addr)
{
u32 value=0;

AFE4490_CS_ENABLE();
delay_us(10);

//SPI_READ寄存器位先写1
AFE4490_WriteData(0x00000001,0x00);
delay_us(1);

//读取数据
SPI3_ReadWriteByte(addr);//写地址
value |= SPI3_ReadWriteByte(0x00);//读高8位
value<<=8;
value |= SPI3_ReadWriteByte(0x00);//读中8位
value<<=8;
value |= SPI3_ReadWriteByte(0x00);//读低8位
delay_us(10);

AFE4490_CS_DISABLE();
return value;
}

//芯片初始化
void AFE4490_Init(void)
{
//初始化IO配置
AFE4490_SPI_init();
//初始化寄存器
AFE4490_WriteData(0x00000000,0x00);
AFE4490_WriteData(0x00001770,0x01);
AFE4490_WriteData(0x00001F3E,0x02);
AFE4490_WriteData(0x00001770,0x03);
AFE4490_WriteData(0x00001F3F,0x04);
AFE4490_WriteData(0x00000000,0x05);
AFE4490_WriteData(0x000007CE,0x06);
AFE4490_WriteData(0x000007D0,0x07);
AFE4490_WriteData(0x00000F9E,0x08);
AFE4490_WriteData(0x000007D0,0x09);
AFE4490_WriteData(0x00000F9F,0x0A);
AFE4490_WriteData(0x00000FA0,0x0B);
AFE4490_WriteData(0x0000176E,0x0C);
AFE4490_WriteData(0x00000002,0x0D);
AFE4490_WriteData(0x000007CF,0x0E);
AFE4490_WriteData(0x000007D2,0x0F);
AFE4490_WriteData(0x00000F9F,0x10);
AFE4490_WriteData(0x00000FA2,0x11);
AFE4490_WriteData(0x0000176F,0x12);
AFE4490_WriteData(0x00001772,0x13);
AFE4490_WriteData(0x00001F3F,0x14);
AFE4490_WriteData(0x00000000,0x15);
AFE4490_WriteData(0x00000000,0x16);
AFE4490_WriteData(0x000007D0,0x17);
AFE4490_WriteData(0x000007D0,0x18);
AFE4490_WriteData(0x00000FA0,0x19);
AFE4490_WriteData(0x00000FA0,0x1A);
AFE4490_WriteData(0x00001770,0x1B);
AFE4490_WriteData(0x00001770,0x1C);
AFE4490_WriteData(0x00001F3F,0x1D);
AFE4490_WriteData(0x00000101,0x1E);
AFE4490_WriteData(0x00000000,0x1F);
AFE4490_WriteData(0x00000000,0x20);
AFE4490_WriteData(0x00000000,0x21);
AFE4490_WriteData(0x0001BEBE,0x22);
AFE4490_WriteData(0x00000000,0x23);
AFE4490_WriteData(0x00000000,0x24);
AFE4490_WriteData(0x00000000,0x25);
AFE4490_WriteData(0x00000000,0x26);
AFE4490_WriteData(0x00000000,0x27);
AFE4490_WriteData(0x00000000,0x28);
AFE4490_WriteData(0x00000000,0x29);
AFE4490_WriteData(0x00000000,0x2A);
AFE4490_WriteData(0x00000000,0x2B);
AFE4490_WriteData(0x00000000,0x2C);
AFE4490_WriteData(0x00000000,0x2D);
AFE4490_WriteData(0x00000000,0x2E);
AFE4490_WriteData(0x00000000,0x2F);
AFE4490_WriteData(0x00000000,0x30);
}

能告诉我afe4490外围电路怎么设计的吗

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top