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.

Beaglebone GPIO interrupt example

Hi,

I'm able to runs examples provided by Starterware for AM335x on my Beaglebone,and right now trying to use interrupt on GPIO pins. I'm able to configure the mux for the input pins that I'm using but it still not generating the interrupt.

Can anyone help me with sample code to activate/use interrupt on GPIO pins?

Regards,

Yovi

  • Hi Yovi,

              For Beaglebone we dont have any sample code to demonstrate GPIO as input, but we have code for Output.

              If you can explain which GPIO you are using on beaglebone and how are you generating the interrupt (external GPIO trigger), we will be able to check this.

    Regards

    Baskaran

  • Hi Baskaran,

    Yeah, I check all sample code for BeagleBone as well as sample for EVM board and I couldn't find any code that give me example regarding activating interrupt on GPIO.

    As of now I'm able to use GPIO1_7  (Pin #4 on P8 expansion header of beaglebone), I can read the value correctly which I think proved that my PINMUX setting is correct.

    Unfortunately I'm still not able to use this pin to trigger interrupt. My initial plan is just put a button to simulate the interrupt. If you have sample code on how to use any GPIO pin as interrupt source it should be helpful, cause I guess my problem is on the process to configure interrupt for GPIO.

    Regards,

    Yovi

  • Yovi,

          Before i check the GPIO1_7 for Beaglebone i want to share the GPIO0_2 configuration i did for AM335x EVM to generate interrupts. Attaching the code snippet here for your reference. Please check if this helps. Also i hope you are configuring the interrupt controller properly (are you able to get any other interrupts?).

    #define GPIO_WAKE_INSTANCE         (SOC_GPIO_0_REGS)
    #define GPIO_WAKE_PIN_NUM         (2)

        /* Enabling the GPIO module. */
        GPIOModuleEnable(GPIO_WAKE_INSTANCE);
        
        /* Perform a module reset of the GPIO module. */
        GPIOModuleReset(GPIO_WAKE_INSTANCE);
        
        /* Set the specified pin as an Input pin. */
        GPIODirModeSet(GPIO_WAKE_INSTANCE,
                       GPIO_WAKE_PIN_NUM,
                       GPIO_DIR_INPUT);
                       
        GPIOIntTypeSet(GPIO_WAKE_INSTANCE,
                        GPIO_WAKE_PIN_NUM,
                        GPIO_INT_TYPE_BOTH_EDGE);
                        
        HWREG(GPIO_WAKE_INSTANCE + 0x34) = 0x4;
        HWREG(GPIO_WAKE_INSTANCE + 0x38) = 0x4;
        
        HWREG(GPIO_WAKE_INSTANCE + 0x44) = 0x4;

    Regards

    Baskaran

  • Hi Baskaran,

    Thanks for the snippet  it help, now I'm able to capture interrupt on GPIO pins.

     

    Regards,

     

    Yovi

  • Hi,

    Can u guys please provide the code snippet for initialization of interrupt controller for the GPIO0[2] pin at the rising edge to the pin.

    That will be very helpful.

    Thanks

  • Snippet provided above just add below line and delete that respective line from that code.

    GPIOIntTypeSet(GPIO_INSTANCE_ADDRESS,GPIO_INSTANCE_PIN_A,GPIO_INT_TYPE_RISE_EDGE);