这叫啥问题嘛
void Trans_val(uint Hex_Val)
上面这个函数的作用?
你采样得到的结果是一个0-4095之间的数字,你要把它转化成电压来显示才行吧
举个例子,假设采样结果是987,我们知道对应电压是987/4096*3.3=0.7952V
caltmp = Hex_Val=987;
caltmp = (caltmp << 5) + Hex_Val;=987*33=32571
caltmp = (caltmp << 3) + (caltmp << 1); //caltmp = caltmp * 10=325710
Curr_Volt = caltmp >> 12; //Curr_Volt = caltmp / 2^n=325710/2^12=325710/4096=79.52=79
ptr[0] = Curr_Volt / 100;=79/100=0
t1 = Curr_Volt - (ptr[0] * 100);=79-0*100=79
ptr[2] = t1 / 10;=79/10=7
ptr[3] = t1 - (ptr[2] * 10);=79-7*10=9
ptr[1] = 10;
|