Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

usbd_ble_uart(peripheral) example in the 17.0.2 SDK, LED_0 not working intended

I am currently going through the usbd_ble_uart example and understanding what states make which LED's active,

Within the example, LED_BLE_NUS_CONN  is defined as BSP_BOARD_LED_0, which is the single green LED (LD1) on the dongle.

In the below code snippet taken from the example (I have only added comments), LED_BLE_NUS_CONN should be blinking when advertising, 

static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
    uint32_t err_code;

    switch (ble_adv_evt)
    {
        case BLE_ADV_EVT_FAST:
            err_code = app_timer_start(m_blink_ble,
                                       APP_TIMER_TICKS(LED_BLINK_INTERVAL),
                                       (void *) LED_BLE_NUS_CONN); // this should blink when the dongle is advertising but it doesnt?

and upon connecting to a peer, the LED should stop blinking, and turn on, as seen in the below snippet:

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    uint32_t err_code;

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            NRF_LOG_INFO("BLE NUS connected");
            err_code = app_timer_stop(m_blink_ble); // this should stop LED_0 from blinking
            APP_ERROR_CHECK(err_code);
            bsp_board_led_on(LED_BLE_NUS_CONN); // this should stay on when connected but doesnt?
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            break;

There is no other code in the example that affects that LED.

However, the behaviour I am seeing is:

- Upon powering the dongle LED_0 will flash on once, and then turn off

- Upon a connection event, LED_0 will flash on once and then turn off.

I am unsure why the LED is ever turning off as I cant see any code to indicate that it should be in any other state than blinking, or solid on.

I do not believe this is a hardware issue as I have two dongles both with the same results, and I am able to run a modified blinky example to control the same LED at my will.

Any insight into why this could be happening is appreciated.

Thanks,

Luke

Parents Reply Children
  • Hi, thanks for the reply

    I should have added that I have adapted the example to work for the dongle by setting BOARD_PCA10059 in the preprocessor defines, sorry about that.

    Upon further looking it seems that a bsp_init() with the BSP_INIT_LEDS flag creates an app timer like you said which ends up calling the bsp_led_indication() function which sets the LED's depending on states such as advertising and connecting - at least from my understanding.

    However, it is not only LED_0 that is set by this function, but LED_1 is set in some states such as send and recieve events - I have not noticed LED_1 changing outside of what it should do as per the example.

    As for not using the BSP, from the programming tutorial it states that the:

    "The firmware must set REGOUT0 to 3 V in order to allow it to be debugged from a DK"

    Would I therefore still be able to program the dongle from my PC using nRF Connect's Programmer app?

    Also, would I still be able to put the dongle in DFU mode by pressing the reset button without the BSP?

     

  • Hi,

    With a nRF52840-DK you can both program and debug the nRF52840 Dongle over the SWD interface. Since the nRF52840-DK is fixed 3V, it may not be able to program and debug the nRF52840 Dongle if the REGOUT0 is not set to 3V. If you by accident don't set this register, you may need to un-connect the Dongle from the PC and power the Dongle with 3V to VDD directly during programming and debugging (until you load firmware that have set REGOUT0 again).

    If you program firmware to the nRF52840 Dongle that does not contain the bootloader that is required by the nRF Connect Programmers to be programmed over USB, then it may not be able to program it through USB. In such case you will need to program firmware from the nRF52840-DK that include the bootloader again for it to work as today.

    Kenneth

Related