-
Notifications
You must be signed in to change notification settings - Fork 21
Library Crashed with UART input #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @phantom, |
I used Roger Clark's one from the below URL. I also used his bootloader, so that I can program the STM32 via the USB port. Are you aware of any compatibility issues with Roger Clark's version? |
Honestly, I don't know as I do not know well this lib anyway I guess this should work as using I2C. |
Hi @phantom-8, |
I've tested the Arduino core suggested by fpistm and it works fine with UART receive, no more crashing. So, the problem only happens when using VL53L1X library with Roger Clark's Arduino core. Hi @cparata, I'm using GY-53-L1X like the one from this link. However, I only use the I2C connection on this board. The connection between GY-53-L1X & STM32F1 is very straight forward. Without VL53L1X code, my serial code works fine with Roger Clark's core. It seems to me the problem is due to some conflicts between the VL53L1X library interrupts handling and serial receive interrupts. Below you can find the sample sketch that will result in crashing the stm32 within a couple of minutes when running on Roger Clark's core. You'll need another device to continuously transmit data to the STM32 UART RX1 pin. Without feeding data to the UART RX1 pin, it will not crash. If you need anything else to troubleshoot the problem, please let me know. // This sample will crash the STM32 when you feed data to its UART RX1 pin.
// Remove the "Serial1.beging(115200);" statement or stop feeding data to its UART RX1 pin will stop it from crashing.
//
// Note: Serial is the USB and Serial1 is UART1 (pin PA9 & PA10). The serial port number will shift depending on whether the USB port is enabled.
//
#include <Wire.h>
#include <vl53l1x_class.h>
VL53L1X s1(&Wire, PB3, PB4);
void setup() {
Serial.begin(115200);
Serial1.begin(115200); // Remove this statement and the stm32 will no longer crash
for (int i = 0; i < 10; i++) {
Serial.println("Starting up...");
delay(500);
}
Wire.begin();
s1.InitSensor(0x52);
s1.VL53L1X_StartRanging();
}
void loop() {
uint8_t ready;
uint32_t d;
do {
s1.VL53L1X_CheckForDataReady(&ready);
} while (!ready);
s1.GetDistance(&d);
Serial.print("Distance: ");
Serial.println(d);
s1.VL53L1X_ClearInterrupt();
} |
Hi @phantom-8 , |
@cparata & @fpistm, thanks a lot for helping me to find a solution to the problem. The reason that I use Roger's core is because it supports stm32 programming via USB port. As I understand, the STM32duino core doesn't support the USB port on the blue pill. Is there any other core that supports the USB port and also compatible with the VL53L1X library? |
DFU should be available in the next release of the core, see stm32duino/Arduino_Core_STM32#415 |
@fpistm, great! Thanks for link. I'm new to all these STM32duino and wasn't aware there are quite a few different cores until you told me. Anyway, I'll try to apply the PR and see if I can get it to work. |
When I add more VL53L1X sensors, namely 6, a similar serial receive problem occurred even on stm32duino core. Sometimes, the messages were delayed a few seconds on the UART receive, or it can disappear altogether. Unlike the Roger Clark's firmware, on the stm32duino, it didn't crashed, only problematic UART receive. The pull-up resistance on the I2C bus is fine, it currently at around 2KOhm. I tend to believe the UART receive problem on stm32duino & Roger Clark's firmware may be related. |
Hi @phantom-8 , |
See my comment here: #7 (comment) |
Hi @phantom-8 , |
I'm using the VL53L1X library in polling mode on a stm32 F1 (blue pill). The system would hang if I use the library together with UART input. The library works fine if I'm not using UART. I've tested all 3 UARTs and they all exhibit the same problem.
To reproduce the problem, do the following to a simple test program which uses VL53L1X library:
Remove the "Serial1.begin() or stop sending data to its UART RX1 pin would solve the problem, but we can't use any of the UARTs for receiving data.
The text was updated successfully, but these errors were encountered: