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.

CC2530 Interrupt Enable a GPI pin



Hi guys,

I'm trying to enable Port0 pin 6 as an input Interrupt pin, so when a switch is externally flipped, it will cause an LED to go on.

If you could help me write the simple code, I'd appreciate it.

Thanks,

Reza

  • Hello Reza,

    You should be able to find an example using interrupts in the examples folder.  If you search for GPIO_Interrupt_Init(void);  You first have to enable the interrupt:

      /* Enable interrupts */
      HAL_ENABLE_INTERRUPTS();

    That function will initialize the pin you want to use for the interrupt.  Here is an example of the initialization.  Search the both the files and the User Manual to see how and why these register values are set.

      P1IFG = 0;                // clear all interrupt flags for P!
      P1DIR &= ~BV(5);  // set bit as input
      PICTL |= BV(5);       // enable interrupt on Bit
      PICTL |= BV(0);       // enable rising and falling edge interrupt
      P1IFG &= ~BV(5);   // clear interrupt flag
      P1IEN |= BV(5);      // enable P1 interrupt
      P1 = 0x10;               // All pins on port 1 to low except P1_5 (button)

    Then search the files for the ISR routine and read the HAL documentation pdf on how to implement it.

    HAL_ISR_FUNCTION( MyIsr, P1INT_VECTOR )

    Inside the ISR routine you will clear the appropriate flags for the interrupt that has occured after your code section

    ///.... your code here

      /*
        Clear the CPU interrupt flag for Port_1
        PxIFG has to be cleared before PxIF
      */
      HAL_KEY_LS_PXIFG = 0;

      HAL_KEY_CPU_PORT_1_IF = 0;

    This is just a guide to get you started.  You will have to read the documentation, look through the code and then search the forum for specific problems you are having.

    Thanks,

  • hey,

    Thanks a lot for replying and helping me get on my way. I really appreciate it.

    could you be more specific as to where the examples folder and the user files are?

    thanks,

    Reza

  • Hi,

    You can refer to hal_key.c in \your TI installation folder\ZStack-CC2530-2.5.1a\Components\hal\target\CC2530EB.