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.

Parents
  • Hi,

    Maybe I misunderstood you, but It doesn't  look like the wakeup pin is connected to pin 14. I can't see that any of the BSP buttons from 0-3 is assigned to this pin? 

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

    Also, does this mean that you've activated the internal pullup? 

    regards
    Jared 

  • Jared,

    Thanks for the response.  You are correct that there is nothing connected to pin 14 on the development board which the schematic labeled (Wakeup).  I am trying to use pin9 to trigger a wakeup event which is connected to SW3.

    When I enabled pull-ups, I can confirm that pin configuration is occurring because the pin voltage is pulled high just after the init function (when stepping through the code).

    ret_code_t err_code = bsp_init( BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
    

    I assumed that I could trigger a wakeup event from other pins other than the one that is expressly labeled Wakeup on the schematic.  Is there separate configuration to enable this?  Regardless, the chip is already waking up for BLE events advertising at 100ms or 333 ms intervals as I've configured and flashing the LED at 1000ms off 200ms on intervals where I would assume that a button push event could also be trigger.  If a button is/had been pressed during one of those events shouldn't it call the callback routine?

    Thanks,
    Ben

Reply
  • Jared,

    Thanks for the response.  You are correct that there is nothing connected to pin 14 on the development board which the schematic labeled (Wakeup).  I am trying to use pin9 to trigger a wakeup event which is connected to SW3.

    When I enabled pull-ups, I can confirm that pin configuration is occurring because the pin voltage is pulled high just after the init function (when stepping through the code).

    ret_code_t err_code = bsp_init( BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
    

    I assumed that I could trigger a wakeup event from other pins other than the one that is expressly labeled Wakeup on the schematic.  Is there separate configuration to enable this?  Regardless, the chip is already waking up for BLE events advertising at 100ms or 333 ms intervals as I've configured and flashing the LED at 1000ms off 200ms on intervals where I would assume that a button push event could also be trigger.  If a button is/had been pressed during one of those events shouldn't it call the callback routine?

    Thanks,
    Ben

Children
  • soccerno16 said:

    I am trying to use pin9 to trigger a wakeup event which is connected to SW3.

    When I enabled pull-ups, I can confirm that pin configuration is occurring because the pin voltage is pulled high just after the init function (when stepping through the code).

    I see.

    soccerno16 said:
    I assumed that I could trigger a wakeup event from other pins other than the one that is expressly labeled Wakeup on the schematic.  Is there separate configuration to enable this?  Regardless, the chip is already waking up for BLE events advertising at 100ms or 333 ms intervals as I've configured and flashing the LED at 1000ms off 200ms on intervals where I would assume that a button push event could also be trigger.  If a button is/had been pressed during one of those events shouldn't it call the callback routine?

    It should. When the application goes into idle_state_handle(), it will effectively spin in a WFE() IDLE loop until any event is produced. So a button press should wake it up and invoke the callback handler. It's definitely clear from the schematic that you provided that P0.09 is connected to the SW3. But looking at the datasheet for MDBT42TV I can not see any P0.09 pin:

    More specifically, looking at the nRF52805 schematic, it doesn't have any P0.09 GPIO:

    So something is not correct here. Either I'm not looking at the module that you're using, or you're not using the module that you think you are. Could you elaborate? And please share the correct datasheet for the module that you're using.

    IF you're unsure what chip the module you're using is based on, you can read out the FICR PART register by using nrfjprog tools:

    nrfjprog --memrd 0x10000100

    Seems like you're module is based on the nRF52832.

    Thank you!

    regards

  • You are correct.  I'm conflating two boards.  The MDBT42 development board has a nRF52832 chip.  I intend to use this development board to develop code for a custom board with a nRF52805 chip, but for simplicity i'll just use the dev board for now.

    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.  My provided solution also connected pins 9, 11,12,13 and did not trigger an interrupt.  As mentioned before some aspect of the GPIO configuration seems to work since the pin does get pulled high during init.

    Back to conflating boards, the project i got "somewhat" working is the pca10040e (nRF2810 with SW configurations mods for a nRF2805 actually running on a nRF2832).  I've since tried to open the pca10040 which should be much closer to working right out of the box since it's supposed to target the nRF2832 board.  This project I can't seem to quite get working as well as the other.  Initially i got an IRQ multiple definition error and the dev forums let me to disable UART_LEGACY_SUPPORT.  Then i got a heap and stack size error, so I reduced the heap size down to 1024.  The project runs but no longer get the NRF log prints.

  • 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 

Related