Hello everyone,
I'm facing a weird issue where the nRF52832 would reset and upon reading the RESETREAS reg, the value is 0x10001 which, from the data sheet, indicates that there was a "Reset from pin" and also a "reset due to wake up from System OFF mode when the wakeup is triggered from DETECT from GPIO". This happens when sensor is just lying on my desk and there is little to no movement to it.
It's connected to a Segger J-Link which I'm using to flash and log data from the sensor.
To give some more information, I'm using FreeRTOS and NOT using any softdevice and I'm also running a custom firmware and not any of the examples.
The sensor is reading from an accelerometer interfaced to nRF52 using I2C and there's an interrupt pin of the accelerometer interfaced to one of the GPIOs (configured as an interrupt too) of nRF52. The interrupt from the the accelerometer is used to indicate when data is ready to be read. This allows to nRF52 to sleep and only read when data is ready.
The configuration of the GPIO as interrupt is as follows:
// using an array here to make it easier for future use // in case if more gpio need to init as interrupt static const uint8_t accel_isr_pin[] = {2}; static void interrupt_init(void) { ret_code_t ret_val = NRF_SUCCESS; if (nrf_drv_gpiote_is_init() == false) { ret_val = nrf_drv_gpiote_init(); if (ret_val != NRF_SUCCESS) { trace(TRACE_DEBUG, "error: %d", ret_val); } } nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false); // edge sense from low to high config.pull = NRF_GPIO_PIN_PULLDOWN; for (uint8_t i = 0; i < sizeof(isr_pin); i++) { // configure and enable interrupt lines ret_val = nrf_drv_gpiote_in_init(accel_isr_pin[i], &config, accel_event_handler); if (ret_val != NRF_SUCCESS) trace(TRACE_DEBUG, "error: %d", ret_val); nrf_drv_gpiote_in_event_enable(accel_isr_pin[i], true); } }
Following are my questions:
1. Is the chip reset stemming from an interrupt received from the accelerometer when the chip is in sleep mode? If yes, how can I prevent the chip from not resetting?
2. Is there anything wrong with the initialization function?
I would really appreciate if someone can help me with this issue.
Thank you,
Dhaval