工具与软件:
我正在尝试在我的定制板上将 i2c 默认地址从0x08更改为0x11。
在 根据 OTP 编程手册写入 I2CARES 寄存器并运行 OTP 之后。
根据手册、在 OTP_WRITE 之后读取地址0x40会返回0x08、但旧地址会保留。
请提供任何建议。
下面的部分代码。 使用网页上提供的 STM32示例代码。
一些虚拟变量添加用于绑定目的
CommandSubcommands (SET_CFGUPDATE);
uint16_t ReadData = BQ769x2_ReadRegister (I2CAddress);
void I2C_WriteReg (uint8_t reg、uint8_t* data、uint8_t length);
BQ769x2_SetRegister (I2CAddress、0x0011、2);
CommandSubcommands (EXIT_CFGUPDATE);
ReadData = BQ769x2_ReadRegister (I2CAddress);
子命令(OTP_WR_CHECK、0x00、R);
uint8_t optdata_0 = RX_32byte[0];
uint8_t optdata_1 = RX_32byte[1];
CommandSubcommands (SET_CFGUPDATE);
DirectCommands (BatteryStatus、0x00、R);
uint8_t batteystat_0 = RX_DATA[0];
uint8_t battystat_1 = RX_DATA[1];
if ((battystat_0 & 0x80)==0x00){
子命令(OTP_WR_CHECK、0x00、R);
if (RX_32byte[0]=>= 0x80){
子命令(OTP_WRITE、0x00、R);
HAL_DELAY (100);
uint8_t OTP = RX_32byte[0];
if (otp = 0x80){
printf ("成功");
}
}
}
CommandSubcommands (EXIT_CFGUPDATE);
CommandSubcommands (BQ769x2_RESET);
