本人想用 ds2756来做个库仑计玩玩,现在用芯片可以测电池电压电流,但是当前电量却一次没反应,请大神们指导指导!
uint read_Acr(void) //读取电量
{
uchar a,b;
uint value;
ds2756rst();
//-------------------------------
ds2756wr(0xCC);
ds2756wr(0x69);
ds2756wr(DS_ACR_MSB);
a=ds2756rd();
b=ds2756rd();
value=a;
value<<=8;
value=value|b;
if(value>0x7fff)
{
value=(~value)+1;
}
value=(int)(value*(6.25)/20); // 1.953uV/R
return(value);
}
void show_ACR(void)
{
uint AC_A,AC_B,AC_C,AC_D;
DS_AR=read_Acr();
AC_A = DS_AR /1000;
AC_B = DS_AR %1000/100;
AC_C = DS_AR %100/10;
AC_D = DS_AR %10;
set_address(3,3); //设置显示坐标 //LCD12864显示
write_data(AC_A+0x30);
write_data(AC_B+0x30);
// write_data('.');
write_data(AC_C+0x30);
write_data(AC_D+0x30);
} |