‎2020-10-12 11:17 AM
Hi everybody , I am not sure about am I writing to the true title but anyways I am asking. I am trying to read data from LSM9DS1 sparkfun IMU sensor using HAL i2c with STM32F4 discovery board. I was succesful and I was getting datas, then something happened and my board start not working.
I am not changing the code but it sometimes work sometimes don't. I try to just read device's adress with the code below to be sure problem is not about code. There is same problem for that code to (code is sometimes working sometimes don't).
I am trying to erase device memory with utilty occasionaly. 65% of time it erase device memory but other times it gives "device couldn't find " error.
What could this problem be caused bye? I changed jumpers and STM's cabel but problem is still same.
Adress finding code :
for(Adress=0; Adress<256; Adress++)
{
if(HAL_I2C_IsDeviceReady(&hi2c1, Adress, 1, 10)==HAL_OK)
{
break;
}
}
Solved! Go to Solution.
‎2020-10-13 04:22 AM
Hi @Mehveş Zehra Doğruel​ ,
the I2C-address scanning code looks OK.
It could be a matter of timings, I mean you could insert a delay in your function or check with an oscilloscope if the I2C line and its pull-up resistors are shaping the digital patterns.
>> I am trying to erase device memory with utilty occasionaly. 65% of time it erase device memory but other times it gives "device couldn't find " error.
Do you refer to the full erase chip of the STM32?
-Eleon
‎2020-10-13 04:22 AM
Hi @Mehveş Zehra Doğruel​ ,
the I2C-address scanning code looks OK.
It could be a matter of timings, I mean you could insert a delay in your function or check with an oscilloscope if the I2C line and its pull-up resistors are shaping the digital patterns.
>> I am trying to erase device memory with utilty occasionaly. 65% of time it erase device memory but other times it gives "device couldn't find " error.
Do you refer to the full erase chip of the STM32?
-Eleon
‎2020-10-13 07:29 AM
Yes I tried to add delay and it start to work well. Thank you very much.:thumbs_up:
And yes, ı was using full chip erase. I still don't know why is this problem but it don't prevent my work now, so ı think ı am ok with it . :face_with_tears_of_joy:
‎2020-10-13 07:34 AM
;)