This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf51 and VL53L0X

Hi everybody!

I hope I am not too late to jump on the nrf51 train, but I had the ability to get a great deal on them so I really want to use them for a project we have. We need to connect the chip to a VL53L0X Time-of-Flight sensor and I found this library for it, but I can't wrap my head around how to get it working. I am using the experimental_blinky example from the 12.3 SDK with the 130 soft device. I replaced the main function in the example with the main function from github and also changed the pin configurations as suggested. TWI and TWI0 in sdk_config.h are enabled (along with the log module).

I had a minor success story where I got the library to read the revision from the tof sensor, but is was only one specific reset that worked. I swapped out different chips and different sensors, so I can exclude faulty hardware. The issue is that when I debug the application, it seems to crash (without log, seems like halting) on different places in code from flash to flash. Most of the time I see no output in the Serial Log, or just random characters popping up.

I really hope somebody has a pointer for me, maybe someone is using this combination and can share code. Thanks for the help in advance.

Best regards

Simon

  • Hello Simon,

    Can you try the following for me:

    In your project in SDK12.3.0, go to your preprocessor defines. This is usually found in your project settings. Let me know what IDE (Segger embedded studio, Keil or IAR) you are using, and I can show you how to change them.

    1. Add "DEBUG" to your preprocessor defines. 

    2. Turn off optimization for your project (also done in your project settings). Set it to (-O0).

    3. Set a breakpoint on line 76 in app_error.c.

    4. Start debugging your project.

    Does the application stop at your breakpoint at any point in time? If so, study the .line_num, .error_code and .p_file_name variables, and locate what APP_ERROR_CHECK(err_code) that received an err_code != NRF_SUCCESS (== 0).

    Best regards,

    Edvin

  • Thank you for the response! I am using Keil. I actually narrowed down some things and now I am stuck in the do {} while (!isMeasurementReady()); loop from the github example. Polling the API version and product revision work fine now, but I can' t get any readings since the code is stuck in this loop forever.

    I don't know if I understand the debugger. I turned off optimizations and enabled debugging via preprocessor, but when I run the application in debug mode, it breaks right at the beginning of main(), although I can clearly see some Info logs beyond that point.

  • Ok, so then VL53L0X_GetMeasurementDataReady() is probably never returning true. What HW are you using? The nRF51 DK?

    Try to debug inside VL53L0X_GetMeasurementDataReady() inside vl53l0x_api.c to see if you can figure out why it returns this. This is not our libraries, and I don't have the correct HW to test it, unfortunately. Maybe you can check with the author of the project whether he knows why your project doesn't work.

    But regarding the debugger, what HW do you use? 

    Best regards,

    Edvin

  •         uint8_t buffer[5]; /* Addr + data */
            buffer[0] = index;
            buffer[1] = data >> 24;
            buffer[1] = data >> 16;
            buffer[1] = data >> 8;
            buffer[1] = data;
            ret = nrf_drv_twi_tx(&m_twi_master, address >> 1, buffer, 2, false);
    

    I was going to say that you can use the official library provided by ST and just implement the I2C communication layer to it. Then I had a quick look at that library, and it does just that.

    But the implementation seems to have some issues... Such as the one I pasted above, which is surely wrong.

    If you want to use this library, I'd suggest you focus on  the file that has the I2C routines in it. Fixing that should be sufficient, as the rest is provided by the chip manufacturer.

Related