2019-05-06 12:22 AM
for(uint8_t i=0;i<255;i++)
{
HAL_Delay(10);
if(HAL_I2C_IsDeviceReady(&hi2c1,i,2,20)==HAL_OK)
{
uint8_t address=i;
break;
}
}
2019-05-06 01:41 AM
Are you sure the function HAL_I2C_IsDeviceReady() really probes the bus ?
The I2C address of the MCP3428 is well defined, see section 5.3 of the datasheet, especiall fig. 5-1.
Address bits A2 and A1 are defined by your hardware, A0 by the access type.
No need to guess or probe the bus.
2019-05-06 02:12 AM
you're right bro just before coding i wanted to test whether i could connect it or not as a test
but i couldn't
unbelievably it worked by Arduino
2019-05-06 02:13 AM
At the start of any I2C based IC
I test it by this code