微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 硬件电路设计 > TI电源管理交流 > OV_THRESH_BASE问题

OV_THRESH_BASE问题

时间:10-02 整理:3721RD 点击:

请问一下
我在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

+0.5再将数据类型float转换为unsigned short型,就是为了数据4舍5入取整。

是惯用方法。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top