2020-07-26 01:17 PM
2020-07-26 03:43 PM
I'd use HAL_I2C_Mem_Read() myself.
Getting a NACK from the device?
Try dumping the entire register space, check with a logic analyzer
2020-07-26 01:30 PM
Show us your code, please.
2020-07-26 01:39 PM
uint8_t WHO_AM_I = 0x0D;
uint8_t temp = 0;
I2C_HandleTypeDef* Handle = I2Cx;
/* Format I2C address */
DataStruct->Address = 0x38;
uint8_t address = DataStruct->Address;
/* Check if device is connected */
if(HAL_I2C_IsDeviceReady(Handle,address,2,5)!=HAL_OK)
{
return MM8451_Error;
}
/* Check who am I */
//------------------
/* Send address */
if(HAL_I2C_Master_Transmit(Handle, address, &WHO_AM_I, 1, 1000) != HAL_OK)
{
return MM8451_Error;
}
/* Receive multiple byte */
if(HAL_I2C_Master_Receive(Handle, address, &temp, 1, 1000) != HAL_OK)
{
return MM8451_Error;
}
/* Checking */
while(temp != 0x1A)
{
bug = temp; // i print this value using usart it is 0x00
return MM8451_error ;
}
2020-07-26 03:43 PM
I'd use HAL_I2C_Mem_Read() myself.
Getting a NACK from the device?
Try dumping the entire register space, check with a logic analyzer
2020-07-27 03:20 AM
Thanks,
it is work good now.