ads1118模拟spi驱动问题
ads1118驱动,模拟spi,相关代码如下
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
自己顶
没人再顶,不能沉了
我也刚玩了ADS1118
求份程序,看的我好头大...