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

sd_power_system_off hardfault

Hi,

There is a following initialization in 51822:

static void controls_init(void){

uint32_t err_code;
// Configure pins.
uint32_t pins_transition_mask = (1 << SCKIN_PIN) | (1 << WAKEUP_PIN) | (1 << SLEEP_PIN);

nrf_gpio_cfg_input(WAKEUP_PIN, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_input(SLEEP_PIN, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_input(SDAIN_PIN, NRF_GPIO_PIN_NOPULL);
nrf_gpio_cfg_input(SCKIN_PIN, NRF_GPIO_PIN_NOPULL);

err_code = app_gpiote_user_register(&m_gpiote_user_id,
								0x00,
								pins_transition_mask,
								gpiote_event_handler);

APP_ERROR_CHECK(err_code);
err_code = app_gpiote_user_enable(m_gpiote_user_id);
APP_ERROR_CHECK(err_code);

}

The event handler calling following code when sleep pin asserted:

				err_code = app_gpiote_user_disable(m_gpiote_user_id);
				APP_ERROR_CHECK(err_code);
				nrf_gpio_pin_clear(BLE_ACTIVE);
				nrf_gpio_pin_clear(ADV_PIN_NO);

				// Configure buttons with sense level low as wakeup source.
				nrf_gpio_cfg_sense_input(WAKEUP_PIN,
										 NRF_GPIO_PIN_NOPULL,
										 NRF_GPIO_PIN_SENSE_LOW);
				
				// Go to system-off mode (this function will not return; wakeup will cause a reset)                
				err_code = sd_power_system_off();
				APP_ERROR_CHECK(err_code);

It is similar to the adv_timeout in on_ble_evt but if it is called then controller goes into hardfault state. Could anybody know what's wrong? Advtimeout is working perfectly. I just wanted to put the controller into sleep mode from externally.

p.s.: how can I paste a code snipet properly here? It always formatted wrong... :s

Related