Hello, i am using SDK12.2.0 and SD s130 on a nRF51822 (AC) and i am trying to add an external interrupt on a pin in the cscs ble_peripheral example. The code i am using (and added to example) is this:
#include "app_gpiote.h"
#include "nrf_drv_gpiote.h"
#define SENSORPIN 17
uint32_t pulseCounter = 0;
static void in_pin_handler(void){
pulseCounter++;
}
static void gpio_init(void){
ret_code_t err_code;
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);
in_config.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(SENSORPIN, &in_config, in_pin_handler);
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_event_enable(SENSORPIN, true);}
Then in the begining of main() i have added this to watch for any resets and initialize the interrupt:
SEGGER_RTT_WriteString(0, "Entering main\r\n");
gpio_init();
As soon as gpio_init() is called the MCU resets (Multiple "Entering main" messages). As you can see the interrupt handler is extremely short, so what am i doing wrong here? I'm trying to solve this on my own for quite some time now.
Thanks