cancel
Showing results for 
Search instead for 
Did you mean: 

My code is working as it wishes

MDoğr.1
Associate II

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;

 }

 }

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

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

View solution in original post

3 REPLIES 3
Eleon BORLINI
ST Employee

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

Yes I tried to add delay and it start to work well. Thank you very much.👍

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 . 😂

😉