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

BLE not visible after adding nrf_gpio and twi functions

Hi all, 

I am merging TWI code with BLE.  I started with the ble_app_uart example working perfectly, however, after adding TWI libs and drivers (nrf_twi; nrf_twim; twi_master), and a simple function to blink a led using gpio, the BLE device is not visible anymore. Any help please? 

My code is exactly the ble_app_uart + twi drivers + leds_init function, My leds_init function is bellow.

void leds_init(void)
{
     nrf_gpio_cfg_output(LED_PIN);

	//Turn on the LED to indicate initializing
	
	nrf_gpio_pin_clear(LED_PIN);
	nrf_delay_ms(500);
	// this will switch led on
	nrf_gpio_pin_set(LED_PIN);
	nrf_delay_ms(500);
	// this will switch  led off
	nrf_gpio_pin_clear(LED_PIN);
	nrf_delay_ms(500);
}

Thanks

Parents Reply
  • Hi Amanda, thanks for reply.

    I removed nrf_delay and the same happened, but now the led keep blinking in infinite loop. ( 2 seconds turned on and one turned off)


    I took a fresh ble_app_uart example from sdk 16, and just add the led_init function above.

    Note:  i am uploading this code to a custom board, LED_PIN is pin 11. The code works on DK (PCA10040) nRF52832, but not in my board

Children
  • Hi, 

    Do you have an external LF crystal on the custom board or not?

    -Amanda H. 

  • Hi, yes i do.
    One 32.7 KHz and another of 32 MHz.

    The schematic is quite the same as bellow

  • Hi Alanarf,

    Alanarf said:
    Note:  i am uploading this code to a custom board, LED_PIN is pin 11. The code works on DK (PCA10040) nRF52832, but not in my board

     

    You probably have to change the pin which is used as a LED in the default example from the SDK. The DK uses P0.17 for LED1, so if you are just flashing the default example but has connected his LED to pin 11. well, then it won't work. You have to map the pins in the pca10040.h accordingly to the custom board. 

    In the ble_app_uart example, it uses bsp_board_leds_init to initiate LEDs. You can take a look at the bsp_board_leds_init function. 

    -Amanda H.

  • Hi Amanda,

    Yeap. so i changed the value of LED from 17 to 11 on pca10040 file. Also, commented the call of bsp_btn_ble.h in the main file, and removed the group "Board support" that has the bsp files. 

    Board is still not discovered.  

    So i debugged again, and the board is resetting apparently when try to start the advertising. On ble_advertising.c , it enters on p_advertising->whitelist_reply_expected = false; (line 582) and then reset.

    // Fetch the whitelist.
        if ((p_advertising->evt_handler != NULL) &&
            (p_advertising->adv_mode_current == BLE_ADV_MODE_FAST || p_advertising->adv_mode_current == BLE_ADV_MODE_SLOW) &&
            (p_advertising->adv_modes_config.ble_adv_whitelist_enabled) &&
            (!p_advertising->whitelist_temporarily_disabled))
        {
            p_advertising->whitelist_in_use         = false;
            p_advertising->whitelist_reply_expected = true;
            p_advertising->evt_handler(BLE_ADV_EVT_WHITELIST_REQUEST);
        }
        else
        {
            p_advertising->whitelist_reply_expected = false;
        }

    ble_adv_whitelist_enabled has the value of 0x00 on my code, and so whitelist_temporarily_disabled

  • Hi, 

    Could you compile with the debug mode in the Segger and provide the debug log?

    -Amanda H.

Related