ADC122s021通道一转换正常,但为什么通道二转换输出数据总是跳动?
通道一发送0x00,通道二发送的是0x08。通道一输出比较稳定,且就实际输入电压,但通道二输出从1-3000随机跳动(通道二输入大概1000多毫伏)
请问怎么解决
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
ADC122s021通道一转换正常,但为什么通道二转换输出数据总是跳动?
通道一发送0x00,通道二发送的是0x08。通道一输出比较稳定,且就实际输入电压,但通道二输出从1-3000随机跳动(通道二输入大概1000多毫伏)
请问怎么解决
可以和大家分享下你找问题的方法,碰到同样情况就可以快速解决。
Thanks.
邮箱我就不发了,我直接写在下面吧,方便大家看到,使用的是STM32F103
/* adc122c021 read volltage ------------------------
Select_INv1 = 0x00 IN1
Select INv2 = 0x08 IN2---------------------*/
u16 ReadVol(u16 Select_INv1)
{
u16 ADC_Value_H = 0;
u16 ADC_Value_L = 0;
u16 ADC_Value = 0;
float Voltage_vf = 0; //电池电压值
u16 Voltage_vu = 0; //电池电压值
u8 i;
GPIO_ResetBits(GPIOA , GPIO_Pin_4);
ADC_Value_H = SPI1_Receive_byte(Select_INv1);
ADC_Value_L = SPI1_Receive_byte(0x00);
GPIO_SetBits(GPIOA , GPIO_Pin_4);
ADC_Value = (ADC_Value_H<<8 & 0x0f00) + ADC_Value_L;
Voltage_vf=ADC_Value / 4096.0 * 5000;
Voltage_vu = (u16)Voltage_vf;
return Voltage_vu;
}
u16 SPI1_Receive_byte(u16 In_data)
{
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE)==RESET);
SPI_I2S_SendData(SPI1,In_data);
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE)==RESET);
return SPI_I2S_ReceiveData(SPI1);
}