本帖最后由 dontium 于 2015-1-23 11:36 编辑
unsigned int spi_sendRecvWord(unsigned int c)
{
unsigned int data = 0;
unsigned int shift = 0x8000;
int i = 0;
//while(!(ADS1118_DO_X))
ADS1118_SCK_0;
delay_us(120);
for ( i = 0; i < 16; i++)
{
if (c & shift)
{ADS1118_DI_1;}
else
{ADS1118_DI_0;}
if(ADS1118_DO_X)
data|=shift;
ADS1118_SCK_1;
delay_us(60);
//if(ADS1118_DO_X)
//data|=shift;
ADS1118_SCK_0;
delay_us(60);
(shift) >>= 1;
} return data;
} float ADS1118_V(void)
{
unsigned int adc=0;
unsigned int Config_Register;
float value=0;
Config_Register =0x8393;
ADS1118_CS_0;
while((ADS1118_DO_X))
{ADS1118_SCK_1;
delay_us(60);
ADS1118_SCK_0;
delay_us(60);
}
delay_us(100);
adc = spi_sendRecvWord(Config_Register);
spi_sendRecvWord(0x0000);
/* adc = spi_sendRecvWord(Config_Register);
value=adc;
return value;
} 具体问题是无论我怎么改变写入控制字以及测量输入量,dout返回的都是如下错误波形,大家看看是什麽情况 图一:黄sclk,蓝dout 图二黄sclk,蓝din 图三,黄dout,蓝din
|