AnsweredAssumed Answered

# Voltage conversion in mm91z638

Question asked by prathapreddy pacharapalli on Mar 21, 2019
Latest reply on Mar 25, 2019 by Tomas Vaverka

We are using the VSENSE2 as the voltage sensing pin to measure the voltage.

I simply taken the sample source code and i programmmed my costom board.It is updating the voltage in milli voltages.I refered the code,in that we are dividing the register reading value in the voltage register by 2 by right shifting the value  by one.Please give me the reason for dividing the register value by 2.

Here i am attaching the code where we modify the result register value

if(VsenseGetValue(CH_VSENSE2,&VSensor)) {
#if (ISENSE_GND_REF==ISENSEL)
// ISENSEL is GND reference
//s16Vdrop = (s16)((-Battery.s32mAFilt)/G_SHUNT);
s16Vdrop = (s16)(Current_mA/G_SHUNT); // Calculated shunt drop voltage
//Battery.u16mV = (VSensor>>1)-s16Vdrop; // Calculating the load voltage
Battery.u16mV = (VSensor>>1)                      //Here i am not understanding the reason for dividing the register value
s32VolFiltered=s32VolFiltered+Battery.u16mV;
u16VolCnt++;
#endif

#if (ISENSE_GND_REF==ISENSEH)
// ISENSEH is GND reference
Battery.u16mV = VSensor>>1; // scale to mV and no correction
#endif
}