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

f_write/f_close cause BLE disconnect

Hardware: nrf52832

SDK: 16.0.0 with FreeRtos, 

Softdevice: S132 7.0

I set configMAX_PRIORITIES to 5 and modified nrf_sdh_freertos_init to set BLE task priority to 4.

My sd card maintain task priority is set to 2.

For BLE NUS service:

#define MIN_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS) /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(75, UNIT_1_25_MS) /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
#define SLAVE_LATENCY 0 /**< Slave latency. */
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Connection supervisory time-out (4 seconds). */

The NUS service and SD card function works fine when test them separately. But if Operate SD card during NUS connection, I got disconnect with reason:0x8

I have tried to enlarge INTERVAL to 120ms/175ms, also tried to change SLAVE_LATENCY to 4. Problem still exist.

I searched internet and NRF Dev Zone, found some similar question, but none of them can resolve my problem. So I have to raise a new question here. 

 

  • Hi

    One thing, can you check what the connection supervision timeout is? It might be that the peripheral disconnects while the central (nRF) device is doing the SD card operations. You can try increasing this interval (on both ends) to see if this changes anything.

    Good suggestion, but I'll have to track down an SD card, etc. so I'll need a day or two to get this up and running. 

    Best regards,

    Simon

  • Dear Simon:

        I am very sorry about that I just noticed your name should be Simon and I use Simonr so many times. Sorry for the mistake.

       About the connection parameter, please look following screenshot:

       The timeout value is 5000ms and I think this should be long enough.  And this screenshot also contain the disconnect part.

       Thank you very much for preparing test on your side. Just FYI: the reference link discuss about SDK14.0.0 but tin fact the code should work with SDK14.1.0 (I test it on nRF5_SDK_14.1.0_1dda907) 

  • Hey

    I was able to locate an SD card reader and an SD card, and have been testing Jørgen's application (the ble_app_uart_fatfs_sdk141_keil_gcc_ses.zip example which allowed for debugging in SES). I have tested by using both my phone with the nRFConnect app (for Android), and a second DK with nRFConnect for Desktop but I have not been able to reproduce this error. Whenever I write to the UART.TXT file on the SD card, it returns successfully. Please see the attached debug log below

    Did you make any changes to the example application in order to reproduce this, or did you do anything special on your side in order to trigger this disconnect? Lastly, what SD card reader are you using?

    Best regards,

    Simon

  • Dear Simon:

        I only modified 5 lines of code . Screenshot of compare as beblow:

       I think these modifications should not affect the behavior. So I think your test result is a good news. It seems that this issue is caused  by specific SD card. I will try to find some other SD card to check this issue and get back to you.

        Thank you very much.

    Best Regards

    Snow

  • Dear Simon:

       Unfortunately,  I tried another 2 different T card and still has the same issue. 

       Is there any possible that this issue related to the FS type? Since my T cards size larger than 4GB, so have to use FAT32 format. What's your T card's FS type? What's the size of your T card?

       BTW: I also try to use nRFConnect on Laptop, but the tool report "low level error". It seems that this tool can not use BT function on Laptop and need external hw support?

    did you do anything special on your side in order to trigger this disconnect?

    No, I just use nRF Toolbox(Android version) UART sub function to send out NUS string.

    what SD card reader are you using?

    If you mean "Reader", my reader is onboard as following pic:

Related