Hi,
I am trying to merge working code that places the microcontroller in system_off when a switch connected to pin 16 is opened. It then wakes up the micro controller when switch is closed. The same pin is used to achieve this using GPIOTE. The challenge occurs when I merge this with the ble_proximity app. I can never get the chip to go to sleep when I remove the physical ground connector on PIN 16 and open the switch. However it worked perfectly when not merged with ble_proximity
I am effectively using method two neatly described here
I have found some useful information in the discussion below.
https://devzone.nordicsemi.com/f/nordic-q-a/37328/gpio-interrupt-with-ble-peripheral-code
It reveals that the conflict in the
Fullscreen1buttons_leds_init(&erase_bonds);
function needs to be dealt with which I believe I have done.
So changes I have made are to file pca10040.h
//#define BUTTONS_NUMBER 4 - change to 3
#define BUTTONS_NUMBER 3
so only the first three buttons are initialised effectively liberating pin 16
My code is as per below and there must be something incorrect with the configuration of pin 16 as the in_pin_handler is never called.
#define SWITCH_PIN BUTTON_4 #define PIN_OUT LED_4
Fullscreen123456789101112131415161718192021/*** @brief Interrupt handler for wakeup pin*/void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action){ret_code_t err_code;NRF_LOG_INFO("ON WAKEUP SWITCH PIN state is: %d..", nrf_gpio_pin_read(pin));if (pin == SWITCH_PIN){//Turn off LED to indicate the nRF5x is in System-off modeNRF_LOG_INFO("Turn off LED to indicate the nRF5x is in System-off mode");nrf_drv_gpiote_out_set(PIN_OUT);//Disable power-down button to prevent System-off wakeupNRF_LOG_INFO("Disable power-down button to prevent System-off wakeup");nrf_drv_gpiote_in_uninit(SWITCH_PIN);nrf_drv_gpiote_in_event_disable(SWITCH_PIN);//Configure wake-up button
Any help greatly appreciated as to where I am getting this wrong.
Best,
DW