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

Regarding the Uart not working as per intended in release mode... or without the debugger connected to the chip

Hi , 

In my application .. I have define two custom characteristics one with write permission and other with read + notify permission... 

Whenever a value is written to the characteristics with write permission it is transmitted over uart to my MCU as it is..

The string recieved by the  MCU is processed and the appropriate response string is sent  back to the nrf52810 chip over uart, which inturn updates the characteristics with read + notify permission.

Above mentioned functionality  is working fine when the chip is connected to my Debugger/Programmer (nrf52840 DK ) and the application is run in Debug Mode..

but when Debugger is disconnected and board is power cycled...  I could write data to write characteristics and it is written as expected over uart to my MCU, My MCU is forming the response and sending the same over UART to NRF52810 chip  (This is been verified physically over uart lines and also reading my MCU UART registers in Debug Mode)

the Data received over the UART by the NRF52810 chip as response to  is not updated over the read  + notify characteristics... 

Can you please help to understand, where should i look or how should I overcome this issue.

Please find enclosed code for your review and comment... suspect it has something to do with the timing, but not sure how to work around on the same, as it seems to work perfectly fine when the application is run over my PC with the debugger connected to the NRF52810 chipset

Thanks and Regards

Sijeo Philippca10040e.rar

  • Hi,

    I cannot see any obvious issues in the code. Do you have any logging capabilities in the device? If you have, can you add some logging around the code to see if it is executed as expected without the debugger connected?

    Since the nRF52840 has two UARTE interfaces, it is possible to run UART logging alongside the UART used by your application.

    Best regards,
    Jørgen

  • Hi, 

    Currently we are using NRF52810 in our application and using the SWD interface of NRF52840 DK to program and Debug

    ... Probably Can use a IO to toggle around the code.... 

  • Of course, my bad. I read nRF52840 DK in the post, but I see that this was only used for debugging. GPIO toggling should work as well. You can also try to use the RTT logging backend, but this requires the debugger to be connected. It may interfere with recreating the issue.

  • # SEGGER J-Link RTT Viewer V6.81c (beta) Terminal Log File
    # Compiled: 17:41:02 on Jun 19 2020
    # Logging started @ 20 Jun 2020 21:13:01
    00> <info> app: DisConnected.
    00> 
    00> <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Encryption
    00> 
    00> updating the custom valueNotification Done<info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: DisConnected.
    00> 
    00> <info> peer_manager_handler: Connection secured: role: Peripheral, conn_handle: 0, procedure: Encryption
    00> 
    00> updating the custom valueNotification Done<info> app: Fast advertising.
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Fast advertising.
    00> 
    00> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Fast advertising.
    00> 
    00> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Fast advertising.
    00> 
    00> <info> app: DisConnected.
    00> 
    00> <info> app: Fast advertising.
    00> 
    00> <info> peer_manager_handler: Connection security failed: role: Peripheral, conn_handle: 0x0, procedure: Bonding, error: 4352
    00> 
    00> <info> app: Disconnected.
    00> 
    00> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Fast advertising.
    00> 
    00> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Sleep Mode.
    00> 
    00> <error> app: Fatal error
    00> 
    00> <warning> <info> app: Fast advertising.
    00> 
    
    RTT Logging seems to be a good idea... attaching the log for your review and comment... One thing i could come accross was Once the data is recieved through UART ble_cus_custom_value_update function is called... 

    Sometime the err_code = sd_ble_gatts_hvx( p_cus->conn_handle, &hvx_params ) is executed and successfully updates the notification characteristics on the nrf connect soon after  it switches to fast advertising mode and then disconnects, 

    Sometimes after executing sd_ble_gatts_hvx( p_cus->conn_handle, &hvx_params ) api in the application, the data is not updated on the apk as it quickly switches over to fast advertising mode and disconnects after which it ends up in Fatal Error

    Please do let me know if possible how I can avoid the device going to fast advertising mode and then leading to disconnection... any pointers for me to look into

  • Also would like to add that the nrf Connect is giving Error as 

    Error 22 (0x16): GATT CONN TERMINATE LOCAL HOST...

    Is this something to do with the mobile device... i.e. disconnecting my device... 

    Will try to get the sniffer log ASAP to help towards resolution.. 

    Please do let me know if I need to look into anything else in my code meanwhile.. 

Related