2022-12-20 11:49 PM
Hello,
I am currently working with STM32wl55jc. My application invlolves few I2C sensors.The application also invlolves VL53l0x. These sensors have been mounted on a single PCB.
I have tried explaining the problem below.
1. I am currently reading the sensor data every minute. And Transmitting it over to the LoRaWAN server.
2. All the sensors have different addresses.
3. The product works fine for some amount of time and then while reading data from VL53l0x the I2C-SCL line goes low.
I have conducted two tests.
1. Reading all the sensors EXCEPT Vl53l0x.
The application reuns fine for few hours without facing any issues on the I2C line.
2. Reading data from ONLY VL53l0x
The application misbehaves after some time.
3. Connecting ALL the sensors to STM32G491RE.
The failure doesn't take place.
The I2Cfailure is only seen when Vl53l0x is connected to STM32wl55jc and that too after hours.
The failure of I2C is uncertain. Sometimes it is observed within 2 hours, sometimes after 3 hours or even more than that.
Thank you.
2022-12-21 08:26 AM
Hi @Snatu,
check the error flags in the I2C status register. These may include some hint. It's a specific data read or it can happen during any data read? When there's a timeout on the I2C SCL being forced low, a flag is raised in the register. You can try to reinitialize the I2C or use GPIO to reset the sensor if that doesn't help.
The STM32G4 and the STM32WL use virtually identical instance of the I2C interface, unless the second core of the WL is somehow involved, I see no reason for these two to differ in this case.
BR,
J
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-21 08:40 AM
Data reading from VL53l0x fails over I2C
Hi there,
Currently, I am working with the STM32wl55jc microcontroller. There are few I2C sensors that I use in my application. The application also uses a VL53l0x that I use in the application. A single PCB has been used to mount all of these sensors.
Below I have tried to explain the problem in as much detail as I can.
Assume the following. As of right now, I am reading the sensor data every minute. And Transmitting it to LoRaWAN.
The second point. There are different addresses for each of the sensors.
The third point. For some time, the product works fine, and then it goes low on the I2C-SCL line during the reading of data from the VL53l0x.
2022-12-21 09:31 PM
Hello @JHOUD
Thank you for your reply.
I will check the I2C status register.
The problem doesn't occur during reading any specific register, can happen while reading any of them.
I have implemented the solution suggested by you, by reinitializing the I2C peripheral and, resetting the sensor using XSHUT pin(in the current design I have pulled it up, so I toggled it once using a GPIO).
I will test this for a few days, will post if I face any further problem. Thank you for the suggestion.
Regards,
Sumedh
2023-01-09 03:13 AM
Hello @JHOUD
I have tried resetting the sensor after the communication failure.
The success rate of this approach was not 100%. I could see the GPIO Pin toggle on the logic analyzer. The sensor responded to the reset on several instances but it also behaved otherwise by not responding to the reset.
the second approach which was taken up to resolve this issue was to toggle the SCL pin and reset the sensor upon failure of the I2C communication. This approach gave similar results as above.
Now, I am implementing a software reset upon the I2C failure along with the sensor reset. It seems to work fine now.
When I put my system on debug mode, following was the status of I2C registers. It shows me that BIT 15, i.e. BUSY is set in ISR. I have attached the screenshot.
Regards
2023-01-09 03:20 AM
another doubt that I had was regarding the uncertainty of sensor responding to the reset.
What can be the reason for that?
2023-01-19 06:57 AM
Hi @Snatu,
I'm not expert on this particular sensor, just see if the parameters from the sensor datasheets are met in your application. What is the connection between the sensor IC and the MCU? PCB or some loose wires? Pull-ups are applied externally?
BR,
J
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-01-21 08:34 AM
Do you implement an I2C error recovery if SDA is low prior generating a Start bit ?
Example of I2C bit banging with error recovery here