Home/Support/Support Forum/Using EIRQ3 in a new project
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Using EIRQ3 in a new project

0 votes
HI All,

I need to use an external interrupt for a new project with the 9P module.

EIRQ3 on GPIO101 seems to be reasonably free(only used on dev board for I2C IO) and does not conflict with other signals.

I therefore started with the sample application "Wakeup Interrupt Sample" and have tried to modify it to use EIRQ3. This used the wakeup button on the dev board and shows how to use EIRQ2.

I have revised the interrupt routine, hopefully to clear EiRQ3 as follows

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static int pdirq3Isr(void *context)
{
static int level = 1;

(void) context;

/* clear the interrupt */
narm_write_reg (NA_SCM_EICR_REG, NA_SCM_EICR_3_ADDRESS, clr, 1);
narm_write_reg (NA_SCM_EICR_REG, NA_SCM_EICR_3_ADDRESS, clr, 0);

naGpioSetOutputValue(GPIO_USER_LED1, level++);
level %= 2;
naGpioSetOutputValue(GPIO_USER_LED2, level);

return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Within the GPIO configuration function I have set up the GPIO as an iinterrupt:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ret = naGpioSetInterrupt(101, 1, 1);
if (ret != EXTERNAL3_INTERRUPT)
{
printf("naGpioSetInterrupt(101) returns %d.\n", ret);
return ret;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I then set up the ISR with:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ret = naIsrInstall(EXTERNAL3_INTERRUPT, pdirq3Isr, NULL);
if (ret != 0)
{
printf ("naIsrInstall failure[%d]\n", ret);
return ret;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

However when I call naIsrInstall the system seems to crash.

Can anyone offer any advice where I am going wrong

Regards
Roy
asked Mar 18, 2009 in NET+OS by rdeabill Community Contributor (142 points)
recategorized Nov 26, 2013 by tuxembb

Please log in or register to answer this question.

2 Answers

0 votes
I tried it out and was able to get it to work.

Make sure you have the latest patches first.

You need to also configure the settings in gpio.h, i.e:

#define BSP_GPIO_MUX_IRQ_3
BSP_GPIO_MUX_USE_3RD_ALTERNATE_PATH

#define BSP_GPIO_MUX_IRQ_3_CONFIG BSP_GPIO_MUX_IRQ_FALLING_EDGE

I then used the following code (attached is the full copy):

int retval, prevCounter = -1;

//setup ISR
retval = naIsrInstall(EXTERNAL3_INTERRUPT, irqIsr, NULL);

if(retval)
printf("Error setting up ISR %d\n", retval);

//setup GPIO
retval = NAconfigureGPIOpin(101, NA_GPIO_FUNC2_STATE, 0);

if(retval)
printf("Error setting up GPIO %d\n", retval);

//watch counter
while(1)
{
tx_thread_sleep(100);

if(prevCounter < counter)
{
printf("Counter %d\n", counter);
prevCounter = counter;
}
}
answered Mar 18, 2009 by charliek Veteran of the Digi Community (408 points)
0 votes
Hi,

Many thanks.

I have it working now with your code
answered Mar 23, 2009 by rdeabill Community Contributor (142 points)
...