您好!
我不明白发生了什么错误。 当数据线就绪时、我读取的是24位、但该值始终相同:0x800000。
我启用 AVDD 电压、等待2秒以确保电压正常、并在测量和测量之间等待15秒、因为更新时间已过。
为什么要获得该值?
这是我的代码:
void ads1231_on ()
{
DO_PIN_AVDD = 1; //启用 AVDD
DO _PIN_ADS_PDWN = 0;
_DELAY_ms (2000);
Do _PIN_ADS_PDWN = 1; //启用 ADS1231
Do _PIN_ADS_CLOCK = 0;
}
void ads1231_off ()
{
DO_PIN_AVDD = 0;
DO _PIN_ADS_PDWN = 0;
}
int24_t ads1231_read ()
{
int24_t data = 0;
int24_t tmp = 0;
int8_t bit_shift;
//等待 IC 准备就绪
while (((DI_PIN_ADS_DATA)==1){};
_DELAY_us (100);
//读取数据
for (bit_shift=23;bit_shift >=0;bit_shift--)
{
DO _PIN_ADS_CLOCK = 1;
_DELAY_ns (200);
tmp = DI_PIN_ADS_DATA;
tmp =(tmp << bit_shift);
data |= tmp;
Do _PIN_ADS_CLOCK = 0;
_DELAY_ns (200);
}
//发送最终时钟信号结束发送
DO _PIN_ADS_CLOCK = 1;
_DELAY_ns (200);
Do _PIN_ADS_CLOCK = 0;
_DELAY_ns (200);
返回数据;
}
void main (void)
{
Setup(); //设置 IO
int24_t value1;
int24_t 值2;
int24_t 值3;
int24_t 值4;
int24_t 值5;
int24_t 值6;
int24_t 值7;
ads1231_on ();
while (1)
{
Value1 = ads1231_read();
_DELAY_us (15);
value2 = ads1231_read();
_DELAY_us (15);
Value3 = ads1231_read();
_DELAY_us (15);
Value4 = ads1231_read();
_DELAY_us (15);
value5 = ads1231_read();
_DELAY_us (15);
value6 = ads1231_read();
_DELAY_us (15);
value7 = ads1231_read();
_DELAY_us (15);
}
}
谢谢!