simondlevy / VL53L5CX

Arduino library for ST Microelectronics VL53L5CX multizone Time-of-Flight ranging sensor
MIT License
27 stars 13 forks source link

Execution getting stuck during init on STM32 with stm32duino #7

Closed joelsa closed 1 year ago

joelsa commented 3 years ago

Hi,

thank you very much for publishing your library for this sensor.

unfortunately on my STM32 (Nucleo F446RE) this code get stuck up during the initialization, as the sensor does not return the expected value in _poll_foranswer, here is a permalink to the corresponding line in code: https://github.com/simondlevy/VL53L5/blob/fa743d1c319c5fd53562447cf11af5ac3199ccfd/src/vl53l5cx_api.cpp#L445

The issue is described here on the ST Community forum too: https://community.st.com/s/question/0D53W000010uFcTSAU/vl53l5cx-driver-vl53l5cxinit-fails The error is attributed to too small RX and TX Buffers. I can see that you have a Fix for some STM32 boards implemented, and have defined ARDUINO_ARCH_STM32, but this does not change the behavior. Are you aware of other issues with STM32 boards?

I am using PlatformIO with the stm32duino, did you use the STM32 for your Ladybug tests too, or did you use Arduino_STM32?

kriswiner commented 3 years ago

I used the STM32L432 (Ladybug) with Thomas Roell's Arduino core for same.

On Fri, Sep 3, 2021 at 7:48 AM Joel Schulz-Andres @.***> wrote:

Hi,

thank you very much for publishing your library for this sensor.

unfortunately on my STM32 (Nucleo F446RE) this code get stuck up during the initialization, as the sensor does not return the expected value in poll_for_answer, here is a permalink to the corresponding line in code: https://github.com/simondlevy/VL53L5/blob/fa743d1c319c5fd53562447cf11af5ac3199ccfd/src/vl53l5cx_api.cpp#L445

The issue is described here on the ST Community forum too:

https://community.st.com/s/question/0D53W000010uFcTSAU/vl53l5cx-driver-vl53l5cxinit-fails The error is attributed to too small RX and TX Buffers. I can see that you have a Fix for some STM32 boards implemented, and have defined ARDUINO_ARCH_STM32, but this does not change the behavior. Are you aware of other issues with STM32 boards?

I am using PlatformIO with the stm32duino https://github.com/stm32duino/Arduino_Core_STM32, did you use the STM32 for your Ladybug tests too, or did you use Arduino_STM32 https://github.com/rogerclarkmelbourne/Arduino_STM32?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/simondlevy/VL53L5/issues/7, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKQ7FTLQWX5JKWCKRK3UADN27ANCNFSM5DL5B7MQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

joelsa commented 3 years ago

Thank you very much @kriswiner

I have a Nucleo-L432KC lying around, so I'll check if it works there for me and look into the differences in implementation between the Arduino Cores.

kriswiner commented 3 years ago

You could also just buy a Ladybug at $15 to test;>!

On Fri, Sep 3, 2021 at 3:39 PM Joel Schulz-Andres @.***> wrote:

Thank you very much @kriswiner https://github.com/kriswiner

I have a Nucleo-L432KC lying around, so I'll check if it works there for me and look into the differences in implementation between the Arduino Cores.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/simondlevy/VL53L5/issues/7#issuecomment-912847747, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKWAUA62XFENAFV4XDTUAFFD3ANCNFSM5DL5B7MQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

joelsa commented 3 years ago

I really like your Hardware Designs and will do that too, but I am based in Germany, so shipping might take a few days.

cparata commented 2 years ago

Hi all, I found the reason why this library does not work with STM32duino Core. Basically the STM32duino Core is not able to manage a WrMulti of 0x8000 bytes in terms of memory. So we just need to split the WrMulti in chunks like the library does for RdMulti and it works also on STM32duino Core. I also found an issue in the I2C address management. It is not set correctly in the library. So I'm going to do a PR that fixes all these issues. Best Regards, Carlo

cparata commented 2 years ago

Here the PR: https://github.com/simondlevy/VL53L5/pull/12

joelsa commented 2 years ago

Hi, and thanks for your comment.

I also found that the implementation returns different return values for Wire.endTransmission(), so that might be an error source too.

cparata commented 2 years ago

Hi @joelsa , you mean the implementation that I uploaded in the PR? Could you add more details about this issue? Best Regards, Carlo

joelsa commented 2 years ago

Sorry, I think I may have got something mixed up there. This was with regard to the Arduino_STM32 library by rogerclarkmelbourne. As you can see in the implementation here: https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F4/libraries/Wire/WireBase.cpp the stop bit parameter for endTransmission is not implemented.

The return values seem to be identical for https://github.com/stm32duino/Arduino_Core_STM32/blob/main/libraries/Wire/src/Wire.cpp and https://github.com/GrumpyOldPizza/arduino-STM32L4/blob/master/libraries/Wire/src/Wire.cpp.

I also tried to do something similar to what you did in order to send larger chunks of bytes but ran into some issues there. Have you successfully tested your changes?

cparata commented 2 years ago

Hi @joelsa , Actually, I tested the library with the STM32duino Core that you can find at https://github.com/stm32duino/Arduino_Core_STM32 and it seems to work on my side after the patch that I did. So, my comments refer to this core. I did not test the library with the core by Roger Clark. Best Regards, Carlo

fpistm commented 2 years ago

Hi @joelsa

Sorry, I think I may have got something mixed up there. This was with regard to the Arduino_STM32 library by rogerclarkmelbourne. As you can see in the implementation here: https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F4/libraries/Wire/WireBase.cpp the stop bit parameter for endTransmission is not implemented.

Roger's core does not follow standard Arduino API for several API. Ref: https://www.arduino.cc/en/Reference/WireEndTransmission

simondlevy commented 1 year ago

Since there is now an stm32duino library for this sensor, I am closing this issu.e