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

nrf51822 gpiote could not enter interrupt routine

Hello I am using SDK12.3 without softdevice on a custom board (with nrf51822 256k flash, 16kram without 32768 crystal).

I have written some code using GPIOTE to detect two buttons (with app_button library) when pressed and it worked no problem on nrf5 dev board.

However when i ported the code to the custom board i found that button press could only wake up the MCU but it won't enter the interrupt routine (button handler function).

Any idea could lead to this problem??

Thanks. MM

Parents
  • Here is my code for nrf5 sdk 12

    static void buttons_leds_init(bool * p_erase_bonds)
    {
     bsp_event_t startup_event;
     uint32_t err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                                 APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                                 bsp_event_handler);
     APP_ERROR_CHECK(err_code);
     err_code = bsp_btn_ble_init(NULL, &startup_event);
     APP_ERROR_CHECK(err_code);
     *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);
    
     #if defined  (NRF52832)
    	// init LED
    	nrf_gpio_cfg_output(LED2);
    	// Set gas sensors manage output pins
    	nrf_gpio_cfg_output(CO_Pin);
    	nrf_gpio_cfg_output(CH4_Pin);
    
    	nrf_gpio_pin_set(CO_Pin);
    	nrf_gpio_pin_set(CH4_Pin);
    	// init BUTTON		
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_0, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);    
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_1, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_2, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);  
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_3, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW); 
    
    	NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
                NVIC_EnableIRQ(GPIOTE_IRQn);
     #elif defined  (NRF51822)
    	// init LED
    	nrf_gpio_cfg_output( LED1 );
                nrf_gpio_cfg_sense_input(BSP_BUTTON_0, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);    
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_1, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_2, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);  
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_3, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW); 
                NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
                NVIC_EnableIRQ(GPIOTE_IRQn);
     #endif	
    }
    
    
    void GPIOTE_IRQHandler(void)
    {
      uint8_t bit;
      if(NRF_GPIOTE->EVENTS_PORT)
      {
    			if((~((NRF_GPIO->IN) >> BSP_BUTTON_0) & 0x01)) val=0x00;
    			if((~((NRF_GPIO->IN) >> BSP_BUTTON_1) & 0x01)) __nop();
    		#if defined  (NRF52832)
    			if((~((NRF_GPIO->IN) >> BSP_BUTTON_2) & 0x01)) __nop();
    			if((~((NRF_GPIO->IN) >> BSP_BUTTON_3) & 0x01)) __nop();
    		#endif
        NRF_GPIOTE->EVENTS_PORT = 0;
      }
    }
    
Reply
  • Here is my code for nrf5 sdk 12

    static void buttons_leds_init(bool * p_erase_bonds)
    {
     bsp_event_t startup_event;
     uint32_t err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                                 APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                                 bsp_event_handler);
     APP_ERROR_CHECK(err_code);
     err_code = bsp_btn_ble_init(NULL, &startup_event);
     APP_ERROR_CHECK(err_code);
     *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA);
    
     #if defined  (NRF52832)
    	// init LED
    	nrf_gpio_cfg_output(LED2);
    	// Set gas sensors manage output pins
    	nrf_gpio_cfg_output(CO_Pin);
    	nrf_gpio_cfg_output(CH4_Pin);
    
    	nrf_gpio_pin_set(CO_Pin);
    	nrf_gpio_pin_set(CH4_Pin);
    	// init BUTTON		
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_0, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);    
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_1, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_2, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);  
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_3, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW); 
    
    	NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
                NVIC_EnableIRQ(GPIOTE_IRQn);
     #elif defined  (NRF51822)
    	// init LED
    	nrf_gpio_cfg_output( LED1 );
                nrf_gpio_cfg_sense_input(BSP_BUTTON_0, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);    
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_1, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_2, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW);  
    	nrf_gpio_cfg_sense_input(BSP_BUTTON_3, GPIO_PIN_CNF_PULL_Pullup, NRF_GPIO_PIN_SENSE_LOW); 
                NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk;
                NVIC_EnableIRQ(GPIOTE_IRQn);
     #endif	
    }
    
    
    void GPIOTE_IRQHandler(void)
    {
      uint8_t bit;
      if(NRF_GPIOTE->EVENTS_PORT)
      {
    			if((~((NRF_GPIO->IN) >> BSP_BUTTON_0) & 0x01)) val=0x00;
    			if((~((NRF_GPIO->IN) >> BSP_BUTTON_1) & 0x01)) __nop();
    		#if defined  (NRF52832)
    			if((~((NRF_GPIO->IN) >> BSP_BUTTON_2) & 0x01)) __nop();
    			if((~((NRF_GPIO->IN) >> BSP_BUTTON_3) & 0x01)) __nop();
    		#endif
        NRF_GPIOTE->EVENTS_PORT = 0;
      }
    }
    
Children
No Data
Related