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.

RTOS/BEAGLEBK: GPIO interrupt issue

Part Number: BEAGLEBK

Tool/software: TI-RTOS

HI 

I am trying to use gpio1[12] pin as an interrupt pin with falling edge detection

And whenever interrupt is generated it has to go to isr and led pin 23 must blink once.

all the other time simply reading gpio1[15] pin and displaying that value.

Now the problem is my code will keeps on displaying the pin15 value ,when i give high to low value to pin12 ,interrupt is generated ,but not going to isr.

Simply the display will stop and after some time board will reset

Can anyone help me what is the problem???

My code is here

 

/* Standard includes. */
#include <stdlib.h>
#include <string.h>

#include "am335.h"
#include "serial.h"
#include "gpio_v2.h"
#include "soc_AM335x.h"
#include "interrupt.h"
#include "evmAM335x.h"
/*****************************************************************************
**                INTERNAL MACRO DEFINITIONS
*****************************************************************************/

#define GPIO_DATA_PORT           (SOC_GPIO_1_REGS)
#define GPIO_CLK_PIN_NUMBER        (12)
#define GPIO_DATA_PIN_NUMBER       (15)
#define GPIO_LED_PIN_NUMBER           (23)
/*******************************************************************************
**                     EXTERNAL FUNCTION DECLARATIONS
*******************************************************************************/


/*****************************************************************************
**                INTERNAL FUNCTION DEFINITIONS
*****************************************************************************/
/*
** A function which is used to generate a delay.
*/
static void Delay(volatile unsigned int count)
{
    while(count--);
}
// A function to blink LED once each time a falling edge is encountered on CLK pin
static void gpio1Isr(void)
{
    //printf("Hello1\n");
    serial_puts(UART0_BASE,"Inside isr\n");
    /*    Clear clk interrupt    */
    HWREG(SOC_GPIO_1_REGS + 0x2C) = 1 << 12;
    HWREG(SOC_GPIO_1_REGS + 0x30) = 1 << 12;
    //printf("Hello2\n");
    /* Driving a logic HIGH on the GPIO pin. */
    GPIOPinWrite(GPIO_DATA_PORT,
                 GPIO_LED_PIN_NUMBER,
                 GPIO_PIN_HIGH);

    Delay(0x3FFFF);

    /* Driving a logic LOW on the GPIO pin. */
    GPIOPinWrite(GPIO_DATA_PORT,
                 GPIO_LED_PIN_NUMBER,
                 GPIO_PIN_LOW);
    Delay(0x3FFFF);
//again enable Falling edge IRQ
    HWREG(GPIO_DATA_PORT + 0x34) = 1 << 12;
    HWREG(GPIO_DATA_PORT + 0x38) = 1 << 12;
    HWREG(GPIO_DATA_PORT + 0x44) = 1 << 12;

}
static void ConfigDataPort(void)
{
    serial_puts(UART0_BASE,"Inside config..........\n");
    /* Enabling functional clocks for GPIO1 instance. */
    GPIO1ModuleClkConfig();

    /* Selecting GPIO1 pins for use. */
    GPIO1PinMuxSetup(15);
    GPIO1PinMuxSetup(23);
    GPIO1PinMuxSetup(12);

    /* Enabling the GPIO module. */
    GPIOModuleEnable(GPIO_DATA_PORT);
    /* Resetting the GPIO module. */
    GPIOModuleReset(GPIO_DATA_PORT);

    /* Setting the GPIO data as an input pin. */
    GPIODirModeSet(GPIO_DATA_PORT,
                   12,
                   GPIO_DIR_INPUT);
    /* Setting the GPIO clock as an input pin. */
    GPIODirModeSet(GPIO_DATA_PORT,
                   15,
                   GPIO_DIR_INPUT);
    /* Setting the GPIO LED as an output pin. */
    GPIODirModeSet(GPIO_DATA_PORT,
                   GPIO_LED_PIN_NUMBER,
                   GPIO_DIR_OUTPUT);

//**************** Check enabling of LED pin ****************
    /* Driving a logic HIGH on the GPIO pin. */
    GPIOPinWrite(GPIO_DATA_PORT,
                 GPIO_LED_PIN_NUMBER,
                 GPIO_PIN_HIGH);

    Delay(0x3FFFF);

    /* Driving a logic LOW on the GPIO pin. */
  /*  GPIOPinWrite(GPIO_DATA_PORT,
                 GPIO_LED_PIN_NUMBER,
                 GPIO_PIN_LOW);
    Delay(0x3FFFF);
*/
//************* Now enable interrupt on CLK pin *************


    /* Initialize the ARM Interrupt Controller */
    IntAINTCInit();

    IntMasterIRQEnable();

    /*    GPIO interrupts    */
    IntSystemEnable(SYS_INT_GPIOINT1A);
    IntPrioritySet(SYS_INT_GPIOINT1A, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_GPIOINT1A, gpio1Isr);
    IntSystemEnable(SYS_INT_GPIOINT1B);
    IntPrioritySet(SYS_INT_GPIOINT1B, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_GPIOINT1B, gpio1Isr);

    /* Setting the GPIO_CLK_PIN_NUMBER to raise IRQ at falling edge of input */
    GPIOIntTypeSet(GPIO_DATA_PORT,
                    12,
                    GPIO_INT_TYPE_FALL_EDGE);

    HWREG(GPIO_DATA_PORT + 0x34) = 1 << 12;
    HWREG(GPIO_DATA_PORT + 0x38) = 1 << 12;
    HWREG(GPIO_DATA_PORT + 0x44) = 1 << 12;

}




/*
 * Starts all the other tasks, then starts the scheduler. 
 */
int main( void )
{   
    unsigned int msDelay;
    unsigned int Read_value=0;

/* Configuring the functional clock for GPIO0 instance. */

	//INIT SERIAL
	init_serial(UART0_BASE);
	serial_puts(UART0_BASE,"Starting BeagleBone\n");
    ConfigDataPort();

    while(1)
    {
         Read_value=GPIOPinRead(GPIO_DATA_PORT,15);
        if(Read_value>0) serial_puts(UART0_BASE,"value>0\n");
        else if(Read_value==0) serial_puts(UART0_BASE,"value=0\n");
        else serial_puts(UART0_BASE,"value<0\n");
        msDelay=0x1FFFFFF;
        while(msDelay--){;}
    

    }
	return 0;
}