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 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.

Children
  • 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.

  • Here is what appears on output 

    Preparing target for download
    Executing Reset script TargetInterface.resetAndStop()
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.
    Downloading ‘s132_nrf52_6.1.1_softdevice.hex’ to J-Link
    Programming 2.7 KB of addresses 00000000 — 00000aff
    Programming 144.3 KB of addresses 00001000 — 0002514f
    J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
    Download successful
    Downloading ‘ble_app_uart_pca10040_s132.elf’ to J-Link
    Programming 46.1 KB of addresses 00026000 — 000318b1
    Programming 0.1 KB of addresses 000318b4 — 0003194b
    J-Link: Flash download: Bank 0 @ 0x00000000: Skipped. Contents already match
    Download successful
    Stopped by vector catch
    Preparing target for user application
    Executing Reset script TargetInterface.resetAndStop()
    Reset: Halt core after reset via DEMCR.VC_CORERESET.
    Reset: Reset device via AIRCR.SYSRESETREQ.

Related