目前做的两块板子都是此情况,测试时接入的电压为12V,芯片供电为3.3V
初始化代码
static INA228_State INA228_0_state = {
/* Configuration and Settings */
.configRegister = (INA228_config_register_rst_NormalOperation | \
INA228_config_register_rstacc_NormalOperation | \
0x0000U | \
INA228_config_register_tempcomp_Shunttemperaturecompensationdisabled | \
INA228_config_register_adcrange_16384mV),
.adcConfigRegister = (INA228_adc_config_register_mode_Continuousbusvoltageshuntvoltageandtemperature | \
INA228_adc_config_register_vbusct_4120us | \
INA228_adc_config_register_vshct_4120us | \
INA228_adc_config_register_vtct_4120us | \
INA228_adc_config_register_avg_1024),
.shuntCalRegister = 0x046BU,
.shuntTempcoRegister = 0x0000U, /* TEMPCO is 0 ppm/°C */
.diagAlrtRegister = (INA228_diag_alrt_register_alatch_Transparent | \
INA228_diag_alrt_register_cnvr_DisableconversionreadyflagonALERTpin | \
INA228_diag_alrt_register_slowalert_ALERTcomparisononnonaveragedADCvalue | \
INA228_diag_alrt_register_apol_Normalactivelowopendrain),
.sovlRegister = 0x7FFFU,
.suvlRegister = 0x8000U,
.bovlRegister = 0x7FFFU,
.buvlRegister = 0x0000U,
.tempLimitRegister = 0x7FFFU,
.pwrLimitRegister = 0xFFFFU,
.adcrange = INA228_config_register_adcrange_16384mV,
.currentlsb = 0.0001,
/* Sensor's I2C bus ID and address */
.busId = 0,
.devAddr = 0x40U,
};
波形
读取代码
INA228_config(INA228_0);
INA228_readReg(INA228_0,INA228_device_id_register);
LCD_Init();//LCD初始化
LCD_Fill(0,0,LCD_W,LCD_H,BLACK);
/* add user code end 2 */
while(1)
{
wk_usb_app_task();
/* add user code begin 3 */
vbus = INA228_getVBUS_V(INA228_0);
// 显示电压值
LCD_ShowFloatNum1(40,2,vbus,5,YELLOW,BLACK,24);
current = INA228_getCURRENT_A(INA228_0);
// 显示电流值
LCD_ShowFloatNum1(40,28,current,5,0x07FF,BLACK,24);
power = INA228_getPOWER_W(INA228_0);
// 显示功率值
LCD_ShowFloatNum1(40,56,power,5,WHITE,BLACK,24);
temp = INA228_getDIETEMP_C(INA228_0);
INA228_readReg(INA228_0,INA228_shunt_cal_register);