This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OV_THRESH_BASE问题

请问一下
我在bq769x0_I2C_sample_code_with_CRC中
关于OVTrip的计算,有写到OV_THRESH_BASE(0x2008)及UV_THRESH_BASE(0x1000)
但我在datasheet在讲OV_TRIP_FULL时,并没有看到要用OV_THRESH_BASE及 + 0.5的地方
请问一下我应该依照sample code的写法,还是依照datasheet去计算?


bqMaximo_Ctrl_G2553.h
#define OV_THRESH_BASE 0x2008
#define UV_THRESH_BASE 0x1000
Registers.OVTrip = (unsigned char)((((unsigned short)((OVPThreshold - Registers.ADCOffset)/Gain + 0.5) - OV_THRESH_BASE) >> 4) & 0xFF);
Registers.UVTrip = (unsigned char)((((unsigned short)((UVPThreshold - Registers.ADCOffset)/Gain + 0.5) - UV_THRESH_BASE) >> 4) & 0xFF);

bq769x0 datasheet:
3. Calculate the full 14-bit ADC value needed to meet the desired OV and UV trip thresholds as follows:
(a) OV_TRIP_FULL = (OV – ADCOFFSET) ÷ ADCGAIN
(b) UV_TRIP_FULL = (UV – ADCOFFSET) ÷ ADCGAIN
4. Remove the upper 2 MSB and lower 4 LSB from the full 14-bit value, retaining only the remaining
middle 8 bits. This can be done by shifting the OV_TRIP_FULL and UV_TRIP_FULL binary values 4
bits to the right and removing the upper 2 MSB.

Thanks