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

Button event is not being generated with example project

Hello, I am working with both QFABA0 devices as well as a QFAAC0. Because of the outdated silicon I am constrained to SDK V4.x and SD V5.x

My current test setup is

I am using custom circuit boards that have worked previously. The software modification is that I have set NRF6310_BUTTON_0 to 30, the location of my button.

This code works:

int main(void)
{
    leds_init();
		nrf_gpio_cfg_input(30, NRF_GPIO_PIN_NOPULL);
	for(;;)
	{
		if (nrf_gpio_pin_read(30))
			nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
		else
			nrf_gpio_pin_set(ADVERTISING_LED_PIN_NO);
	}

therefore, I am convinced the hardware works correctly (LED displays inverse of pin state)

When using the example regularly, button_event_handler is never called. In fact, GPIOTE_IRQHandler is never called either. Something tells me this is related to softdevice interrupt redirection. Could it possibly be my keil toolchain?

  • I have tried adding app_button_enable but the interrupt is still not called

  • This isn't very obvious, but is this in an application which does not use the softdevice? If so, you'll have to manually start the LFCLK, and also make sure to initialize the app_timer module, since app_button depends on it.

    For an example of how to start the LFCLK manually, you can refer to the rtc_example. If this does not solve your problem, can you please supply your full project, so that I can test it here?

  • The nrf6310/ble/ble_app_proximity project is normal so my main function is int main(void) { // Initialize leds_init(); timers_init(); gpiote_init(); buttons_init(); ble_stack_init(); scheduler_init(); gap_params_init(); advertising_init(); services_init(); conn_params_init(); sec_params_init();

    // Start execution timers_start(); app_button_enable(); // added just in case advertising_start(); // Enter main loop for (;;) { app_sched_execute(); power_manage(); } } It does not assert any errors during startup either (advertises correctly and everything). Please find attached project and all relevant files (I have moved to ble_app_template since it is smaller and doesn't have any ble services)

    To test yourself, you need to change the IO pin. I removed all object and binaries, I can supply them if you would like.

    ble_app_template_testbutton.zip

  • As far as I can see, your code works perfectly fine, even without changing IO, when I connect a button on the nRFgo Starter Kit to pin 30 on the nRF51822.

    Are you absolutely sure that you don't have a hardware error of some kind? Have you tried setting this pin as output to see if you actually have contact with the pad?

Related