首先经过验证SPI能够实现正常的工作,可以正确的实现读写寄存器功能。
但是我想通过内部产生一个波形验证芯片是否正常工作,读出来的数据一直是FF 00 00 FF,读取代码如下:
while(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3) == 1);//DRDY引脚
data[0] = SPI_Receive_Send(SPI1,0x00); //获取数据
data[1] = SPI_Receive_Send(SPI1,0x00); //获取数据
data[2] = SPI_Receive_Send(SPI1,0x00); //获取数据
data[3] = SPI_Receive_Send(SPI1,0x00); //获取数据
data[1] = data[1]<<8;
data[2] = data[2]<<16;
/USART_SendData(USART3,data[3]);
delay_ms(1);
USART_SendData(USART3,data[2]);
delay_ms(1);
USART_SendData(USART3,data[1]);
/delay_ms(1);
USART_SendData(USART3,data[0]);
delay_ms(1);
配置寄存器如下:
SPI_Write_REG(ADS1299_CONFIG1,0xD6); //采样频率250SPS 内部时钟失能 0xF6
SPI_Write_REG(ADS1299_CONFIG2,0xD0); //测试信号产生于内部或外部 SPI_Write_REG(ADS1299_CONFIG3,0xEE); //参考和偏置 0xE6
SPI_Write_REG(ADS1299_CONFIG4,0x00); //连续转换模式
SPI_Write_REG(ADS1299_LOFF,0x02); SPI_Write_REG(ADS1299_LOFF_SENSP,0x00);
SPI_Write_REG(ADS1299_LOFF_SENSN,0x00);
SPI_Write_REG(ADS1299_LOFF_STATP,0x00);
SPI_Write_REG(ADS1299_LOFF_STATN,0x00);
SPI_Write_REG(ADS1299_MISC1,0x00);
SPI_Write_REG(ADS1299_MISC2,0x00);
SPI_Write_REG(ADS1299_CH1SET,0x5D); //测试信号
SPI_Write_REG(ADS1299_CH2SET,0x09); //Input Short
SPI_Write_REG(ADS1299_CH3SET,0x09); //Input Short 0X09
SPI_Write_REG(ADS1299_CH4SET,0x09); //Input Short
user151383853:
数据是 24位为单位传输的
如果没有变化, 检查设置和有没有进行 ADC 转换
Shuyan Wang:
兄得,我现在也是测试内部方波,配置和你差不多,但是波形很乱.你现在解决了吗?