Interrupt Callback nRF52805 ble_app_beacon

I working with the MDBT42Q-DB with the nRF52805 module.  I've started from the ble_app_beacon example in SDK 17.1.0.   I was able to compile and run the example in Segger Studio.  I wasn't able to get things to work with Keil.

I'm trying to modify the example to added button response for my onboard buttons.  Ultimately I'd like a button (input) to trigger a wake-up for several minutes (setting a timer) before allowing the beacon to go back into deep sleep.

I modified the pca10050.h to match the pin configuration of the development board:

#define LEDS_INV_MASK  LEDS_MASK

#define LEDS_LIST { LED_1, LED_2 }

#define BSP_LED_0      LED_1
#define BSP_LED_1      LED_2

#define BUTTONS_NUMBER 4

#define BUTTON_1       12
#define BUTTON_2       11
#define BUTTON_3       9
#define BUTTON_4       13
#define BUTTON_PULL    NRF_GPIO_PIN_PULLUP

#define BUTTONS_ACTIVE_STATE 0

#define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4 }

#define BSP_BUTTON_0   BUTTON_1
#define BSP_BUTTON_1   BUTTON_2
#define BSP_BUTTON_2   BUTTON_3
#define BSP_BUTTON_3   BUTTON_4

I added BSP_INIT_BUTTONS and a callback handler for button presses in the leds_init fucntion

void bsp_event_handler(bsp_event_t event)
{
    printf("Event");
    switch(event)
    {
        case BSP_EVENT_KEY_0:
        case BSP_EVENT_KEY_1:
        case BSP_EVENT_KEY_2:
        case BSP_EVENT_KEY_3:
            printf("Event");
            break;
        default:
            break;
    }
}


/**@brief Function for initializing LEDs. */
static void btn_leds_init(void)
{
    ret_code_t err_code = bsp_init( BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
    APP_ERROR_CHECK(err_code);
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    bsp_event_t startup_event;

    log_init();
    timers_init();
    btn_leds_init();

    power_management_init();
    ble_stack_init();
    advertising_init();

    // Start execution.
    NRF_LOG_INFO("Beacon example started.");
    advertising_start();


    // Enter main loop.
    for (;; )
    {
        idle_state_handle();
    }
}

I've enable logging which suggests everything got initialized properly.  The ble_beacon is advertising the custom UUID i've set at the interval I've set both of which I can modify.

<info> PRS: Function: nrfx_prs_acquire, error code: NRF_SUCCESS.
<info> app_timer: RTC: initialized.
<info> GPIOTE: Function: nrfx_gpiote_init, error code: NRF_SUCCESS.
<info> GPIOTE: Function: nrfx_gpiote_in_init, error code: NRF_SUCCESS.
<info> GPIOTE: Function: nrfx_gpiote_in_init, error code: NRF_SUCCESS.
<info> GPIOTE: Function: nrfx_gpiote_in_init, error code: NRF_SUCCESS.
<info> GPIOTE: Function: nrfx_gpiote_in_init, error code: NRF_SUCCESS.
<info> CLOCK: Function: nrfx_clock_init, error code: NRF_SUCCESS.
<info> clock: Function: nrf_drv_clock_init, error code: NRF_SUCCESS.
<info> app: Beacon example started.

I confirmed that the pull-up on SW3 (only default connected switch to pin 9) is being configured with a pull-up as expected.

The status LED is blinking as expected with the advertising indication so I at least modified the LED pins properly.

It's possible some of my configuration, porting the project from pca10040e to support the rNF52805 wasn't completely done properly.  I followed this guide as best I could, but as mentioned about I wasn't successful getting Keil to run, though it seemed to compile.  Segger studio is at least running with some working.

I was using this guide:

https://devzone.nordicsemi.com/guides/short-range-guides/b/getting-started/posts/developing-for-the-nrf52805-with-nrf5-sdk

I put the full project here:

https://github.com/soccerno16/ds

Can you perhaps provide some direction?  I cannot seem to get any sort of interrupt response from the board.

  • Hi,

    So I assume that the latest schematics are correct then?

    soccerno16 said:
    Give the dev board, that would mean that P0.09 is package pin 11?  Package pin 11 should be connected and configured as an IO pin. 

    Not sure what you mean by this. Neither P0.11 or P0.09 is available on the nRF52805, so trying to use any of them for the BSP module doesn't quite make sense when emulating nRF52805 on the nRF52832. Instead, can you try using P0.12 which is present both on the nRF52832 and the nRF52805?

    I see from your schematics that this pin is routed out on a header so that should be ok. Could you also instead of using the logger module, set a breakpoint at the start of the callback handler before the switch case, and see if the program hits the breakpoint when you use the debugger?

    regards

    Jared 

  • Using pin P0.12 does in fact work on both the nRF5232 simulating a nRF5205 and directly on the nRF5205 itself.  It's still curious why the P0.09 didn't work on the nRF5232 with a project that was supposed to compile for the nRF5232 but I am guessing some of the compiler flags were wrong.  For clarification for others,  for P0.12 I assigned BUTTON_1 to 12.  Not the actual package pin number.  I'm guessing pin 9 doesn't work when simulating a nRF5205 chip because that pin doesn't exist on the nRF5205 but it's unclear exactly how the simulation is done.

  • Hi,

    Could you share the list of preprocessor flags that you have set?

    regards

    Jared 

  • Sure in the pca10040e project natively supporting nRF5210 but modified to simulate nRF5205

    APP_TIMER_V2
    APP_TIMER_V2_RTC1_ENABLED
    BOARD_CUSTOM
    CONFIG_GPIO_AS_PINRESET
    FLOAT_ABI_SOFT
    INITIALIZE_USER_SECTIONS
    NO_VTOR_CONFIG
    NRF52805_XXAA
    NRF52_PAN_74
    NRF_SD_BLE_API_VERSION=7
    S112
    SOFTDEVICE_PRESENT

    Sure in the pca10040 project natively supporting nRF5232 

    APP_TIMER_V2
    APP_TIMER_V2_RTC1_ENABLED
    BOARD_PCA10040
    CONFIG_GPIO_AS_PINRESET
    FLOAT_ABI_HARD
    INITIALIZE_USER_SECTIONS
    NO_VTOR_CONFIG
    NRF52
    NRF52832_XXAA
    NRF52_PAN_74
    NRF_SD_BLE_API_VERSION=7
    S132
    SOFTDEVICE_PRESENT

Related