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

uart disable problem

Hi,

I have a problem with uart disable function (app_uart_close();). I started from ble_app_uart example, and I want to disable uart when nobody is connected to the Ble device. 
First I removed uart_init(); and printf from main and then added next to the ble_evt_handler function:

case BLE_GAP_EVT_CONNECTED:
            NRF_LOG_INFO("Connected");
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
            APP_ERROR_CHECK(err_code);
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
            APP_ERROR_CHECK(err_code);
            uart_init();
            break;

case BLE_GAP_EVT_DISCONNECTED:
    NRF_LOG_INFO("Disconnected");
    // LED indication will be changed when advertising starts.
    NRF_UART0->TASKS_STOPRX = 1;
    app_uart_close();
    m_conn_handle = BLE_CONN_HANDLE_INVALID;
    break;

These are just two cases of the function, so on connect I enable the uart and on disconnect, I disable the uart. Problem is when I disable the uart power consumption does not drop and the NRF52 is not low power. In the picture is the part of the power consumption diagram when the device is connected and disconnected:


Is there something I am missing when disabling the uart?

  • Hello Vojislav,

    Vojislav said:
    Sorry for keeping you waiting for my answer.

    No problem at all :)

    Vojislav said:
    It seems that I had something wrong in my hardware setup. Now I do not have the same problem anymore. 

    I am happy to hear that the issue is resolved!
    Do you remember what changes you made to your hardware, to eliminate the extra current draw?

    Vojislav said:
    If you have some ideas about what can be better or some cases I did not cover, please let me know>

    Since I do not know what your application will do, or where/how it will operate, it is hard for me to pinpoint any specific changes to your code.
    It looks to me that you have covered the common events, if that is what you are asking.
    Is there anything specific you would like me to take a closer look at?

    Vojislav said:
    I will keep issue open a bit more, while I do some more tests. 

    Great! I would love to know what caused your initial issue.

    Best regards,
    Karl

Related