Question
HAL_I2C_Mem_Write Stuck
Hi everyone,
i am working on a STM32C011F6P6
i am trying to apply some I2C setting to other chip
normal writing value to corresponding address
but seems the HAL_I2C_Mem_Write function is stucked
these are the read and write function
HAL_StatusTypeDef i2c_write_reg(uint8_t reg, uint8_t send_data ) {
return HAL_I2C_Mem_Write(&hi2c1, SLAVE_ADDRESS<<1 , reg, I2C_MEMADD_SIZE_8BIT ,&send_data, 1 , HAL_MAX_DELAY);
}
uint8_t i2c_read_reg(uint8_t reg) {
uint8_t temp;
if (HAL_I2C_Mem_Read(&hi2c1, SLAVE_ADDRESS << 1, reg, I2C_MEMADD_SIZE_8BIT, &temp, 1, HAL_MAX_DELAY) != HAL_OK) {
// Handle error here
return 0; // Or any default value you prefer
}
return temp; // Success, return the read value
}
these are the code execute
HAL_StatusTypeDef stat2;
stat2 = i2c_write_reg(0x25,0x70);
if(stat2!=HAL_OK){
printf("HAL not ok\r\n");
}
stat2 =i2c_write_reg(0x26,0x07);
if(stat2!=HAL_OK){
printf("HAL not ok\r\n");
}
uint8_t x ;
x = i2c_read_reg(0x25) ;
printf("0x250x%02x\r\n",x);
x = i2c_read_reg(0x26) ;
printf("0x26:0x%02x\r\n",x);
i already have pull up resistor on board
any solution or any thing i can do to identify the real issue?