This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2538 external interrupt

Other Parts Discussed in Thread: CC2538, Z-STACK

Hello Guys ,

I work on a dedicated board with CC2538 mcu ,I tried to run a simple external interrupt with push butto and a led so I used the Switch sample provided by ti and I just changed BSP_KEY_DIR_BASE by the GPIO of my buttons but the interrupt dosent work.

Any help??

Thank you.

  • Can you show the code you revised and which GPI you want to use?
  • Hello ,

    Thank you for response .

    I am using the GPIOB and here the code.

    void HalKeyConfig( bool interruptEnable, halKeyCBack_t cback)
    {
    #if (HAL_KEY == TRUE)
      /* Enable/Disable Interrupt or */
      Hal_KeyIntEnable = interruptEnable;
     
      /* Register the callback fucntion */
      pHal_KeyProcessFunction = cback;  
     
      /* Determine if interrupt is enable or not */
      if ( Hal_KeyIntEnable )
      {
        
        /* Initialize key handler to use interrupts */
        bspKeyInit(BSP_KEY_MODE_ISR);
        
        /* Map function dirKeyIsr to UP, LEFT, RIGHT and DOWN keys */
        bspKeyIntRegister((BSP_KEY_LEFT|BSP_KEY_RIGHT),
                          &interrupt_keybd);
        
        /* Map function selectKeyIsr to SELECT key */
        bspKeyIntRegister(BSP_KEY_SELECT, &interrupt_keybd);
        
        /* Enable interrupts on all keys */
        bspKeyIntEnable(BSP_KEY_ALL);
        
        IntPrioritySet(INT_GPIOB, HAL_INT_PRIOR_KEY);              
        IntPrioritySet(INT_GPIOD, HAL_INT_PRIOR_KEY);     
        
        /* Cancel polling if there is one active */
        osal_stop_timerEx(Hal_TaskID, HAL_KEY_EVENT);
      }
      else
      {
        bspKeyInit(BSP_KEY_MODE_POLL);
        
        if( cback != NULL)
        {
          /* Start polling if callback function is setup*/
          osal_set_event(Hal_TaskID, HAL_KEY_EVENT);
        }
      }
    #endif /* HAL_KEY */
    }

    #define BSP_KEY_DIR_BASE        GPIO_B_BASE     //!< Base for left/right/up/down
    #define BSP_KEY_SEL_BASE        GPIO_D_BASE     //!< Base for Select
    #define BSP_KEY_1               GPIO_PIN_4      //!< PC4
    #define BSP_KEY_2               GPIO_PIN_5      //!< PC5
    //#define BSP_KEY_3               GPIO_PIN_6      //!< PC6
    //#define BSP_KEY_4               GPIO_PIN_7      //!< PC7
    #define BSP_KEY_5               GPIO_PIN_4      //!< PA3
    #define BSP_KEY_ALL             (BSP_KEY_1| \
                                     BSP_KEY_2| \
                                     BSP_KEY_5)     //!< Bitmask of all keys
    #define BSP_KEY_LEFT            BSP_KEY_1
    #define BSP_KEY_RIGHT           BSP_KEY_2
    //#define BSP_KEY_UP              BSP_KEY_3
    //#define BSP_KEY_DOWN            BSP_KEY_4
    #define BSP_KEY_SELECT          BSP_KEY_5
    #define BSP_KEY_DIR_ALL         (BSP_KEY_LEFT|  \
                                     BSP_KEY_RIGHT)  //!< Bitmask of all dir. keys

    void interrupt_keybd(void)
    {
      /* Clear the Power interrupt registers */
      SysCtrlPowIntClear();
     
    #if (HAL_KEY == TRUE)
      /* Read the key before it gone */
      halIntKeys = hal_key_int_keys();
     
      if (halIntKeys && (pHal_KeyProcessFunction))
      {
        (pHal_KeyProcessFunction) (halIntKeys, HAL_KEY_STATE_NORMAL);
      }
    #endif /* HAL_KEY */
     
      CLEAR_SLEEP_MODE();
    }

  • Which pin on GPIOB do you use?
  • I use the 4th and the 5th pin.
  • Pin 4 of GPIO_B is used for BSP_3V3_EN and Pin 5 of GPIO_B is used for BSP_LCD_PWR in Z-Stack. If you use this two pins in Z-Stack, it might conflict.