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

GPIOTE using Pin13-16 on 52DK and BMD-300

I'm using a pin for trigger switch input with the following codes

    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
    in_config.pull = NRF_GPIO_PIN_PULLUP;
    err_code = nrf_drv_gpiote_in_init(TRG, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);
    nrf_drv_gpiote_in_event_enable(TRG, true);

My foundation is the characteristics tutorial. I just added above lines to set up interrupt. I tried a few pins other than 13-16, the application seemed to be running. But when I used any of the above 4 pins, there was no advertising at all. I tried on both 52DK and BMD-300 module. I realized those 4 pins are connected to 4 push buttons on 52DK. I have 2 questions:

  1. Is there any way to reuse those 4 pins on 52DK?
  2. There are no buttons connected by default on BMD-300 module, why couldn't I use those 4 pins either? Is there any setting in the code?

Thanks

Parents
  • Hello xr0428

    In the characteristics tutorial the function buttons_leds_init() is called from main. This in turn calls

    uint32_t err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), bsp_event_handler);
    

    This function is part of the board support (bsp) module, and it configures the buttons and leds of the board you are using. For the 52832DK the board defines are found in the pca10040.h header file. The bsp_init function configures the button pins as GPIOTE inputs with low power events.

    When you add your code for pins 13-16 you are trying to initialize GPIOTE for the same pins as the bsp_init function do. This will then trigger the NRF_ERROR_INVALID_STATE error.

    If you are using a custom board you can create a header file called custom_board.h, and remove pca10040.h from the include list. You can place this file in the same directory as the main.c file, as this path is already added. Then remove BOARD_PCA10040 from the preprocessor symbols and add BOARD_CUSTOM (as defined in boards.h). Your custom_board.h should then contain all pin defines similar to what pca10040.h does.

    Alternatively you can remove BSP_INIT_BUTTONS from the bsp_init() arguments. The function will then not configure the buttons, and you can configure them yourself as you please.

    Best regards

    Jørn Frøysa

  • Hi Jørn, removing BSP_INIT_BUTTONS from the bop_init() gets the following error:

    Name : m_error_data

    Details:{fault_id = 16385, pc = 0, error_info = 536936404, p_assert_info = 0x0, p_error_info = 0x2000ffd4, err_code = 8, line_num = 1177, p_file_name = 0x2be6c "../../../main.c"}

    What's the issue here?

Reply Children
No Data
Related