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

example ble_app_blinky + external interrupt

Hello,

I'm trying to modify example ble_app_blinky from SDK17.0.0. I need external interrupt. But when I try to integrate two functions "static void gpio_init(void)" and "void in_pin_handler()" from example peripheral\pin_change_int into the examples\ble_peripheral\ble_app_blinky, I get a message

<error> app: Fatal error <warning> app: System reset


But if I integrate the code from example pin_change_int into the example ble_app_beacon, the interrupts work without a problem.

What is the source of the problem?

Thanks in advance

SDK_17.0.0_9d13099, nRF52832

Parents
  • But if I integrate the code from example pin_change_int into the example ble_app_beacon, the interrupts work without a problem.

    So I have integrated the two functions for the external interrupt in the example ble_app_beacon.

    //****************************************************************************// 
    // EXT.INTERRUPT GPIOTE
    //****************************************************************************//
    #include "nrf_drv_gpiote.h"
    #define AS_WAKE                   24
    #ifdef BSP_LED_1
        #define PIN_OUT BSP_LED_1
    #endif
    #ifndef PIN_OUT
        #error "Please indicate output pin"
    #endif
    
    void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
        nrf_drv_gpiote_out_toggle(PIN_OUT);
        NRF_LOG_INFO("test %d: %d\n", (int)pin, (int)action); 
    }
    /**
     * @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output,
     * and configures GPIOTE to give an interrupt on pin change.
     */
    static void gpio_init(void)
    {
        ret_code_t err_code;
    
        err_code = nrf_drv_gpiote_init();
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
    
        err_code = nrf_drv_gpiote_out_init(PIN_OUT, &out_config);
        APP_ERROR_CHECK(err_code);
    
        //nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
        nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
        in_config.pull = NRF_GPIO_PIN_PULLUP;
    
        err_code = nrf_drv_gpiote_in_init(AS_WAKE, &in_config, in_pin_handler);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_gpiote_in_event_enable(AS_WAKE, true);
    }
    
    
    //****************************************************************************// 
    // SPI FUNCTIONS
    //****************************************************************************//
    /**
     * @brief SPI user event handler.
     * @param event
     */
    void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                           void *                    p_context)
    {
        spi_xfer_done = true;
        //NRF_LOG_INFO("Transfer completed.");
        /*
        if (rx_spi_buf[0] != 0)
        {
            NRF_LOG_INFO(" Received: %02x,%02x,%02x,%02x,%02x",m_rx_buf[0],m_rx_buf[1],m_rx_buf[2],m_rx_buf[3],m_rx_buf[4]);
            NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
        }
        */
    }

    It works perfectly. But power consumption has increased to 246 uA. Original example ble_app_beacon without external interrupt has power consumption up to 10uA between advertising. If I call the function gpio_init (), I get idle power consumption up to 250 uA. How can I reduce the current?

    Thanks in advance

  • Hi,

    If you are pulling a GPIO pin up to 3V you will get a power consumption of 3V/13kOhm =~ 230mA extra.

Reply Children
No Data
Related