2010-05-07 16:18:44     Not receiving interrupts

Document created by Aaronwu Employee on Aug 21, 2013
Version 1Show Document
  • View in full screen mode

2010-05-07 16:18:44     Not receiving interrupts

Bryan Hilterbrand (UNITED STATES)

Message: 89240   

 

I wrote a simple interrupt handler as a base for the code that I'm going to use in our product, but the rt_intr_wait() function never returns. We've used a scope to verify that there is a signal going to the PG3 pin.

 

I'm using uClinux 2007r1 and Xenomai 2.3.1 - I'm not allowed to upgrade to the latest versions until after we get finished with the current round of changes.

 

 

 

#include <stdio.h>

#include <signal.h>

 

#include <asm-blackfin/mach-bf537/irq.h>

#include <sys/mman.h>

 

#include <native/task.h>

#include <native/intr.h>

 

 

#define INT_STACK_SIZE   0

#define INT_PRIORITY    71

 

RT_INTR             m_genericIntDescriptor;

RT_TASK             m_genericSrvrDescriptor;

int                 m_interruptPin           = 8;

 

 

void generic_irq_server(void *cookie)

{

    int    err           = 0;

    int    running       = 1;

    int    firstTime     = 1;

    int    count         = 0;

    RTIME  lastTicks     = 0;

    RTIME  curTicks      = 0;

    RTIME  elapsedTicks  = 0;

 

    printf("Initializing PG%d IRQ:\n", m_interruptPin); fflush(stdout);

   

    // Create the real-time interrupt

    err = rt_intr_create(&m_genericIntDescriptor, "GENERIC_PORTG_IRQ",

                         IRQ_PG0 + m_interruptPin, I_NOAUTOENA);

    if (err < 0)

    {

        printf("ERROR: Could not create generic real-time interrupt: %d\n", err);

        return;

    }

 

    printf("...IRQ_PG%d object created; entering wait loop\n", m_interruptPin);

    fflush(stdout);

 

    // Run forever

    while (running == 1)

    {

        // Enable the interrupt

        rt_intr_enable(&m_genericIntDescriptor);

 

        err = rt_intr_wait(&m_genericIntDescriptor, TM_INFINITE);

 

        if (firstTime)

        {

            printf("PG%d int alive\n", m_interruptPin);

            firstTime = 0;

        }

       

    }

}

 

 

static void clean_exit(int sig)

{

    int err;

 

    rt_intr_disable(&m_genericIntDescriptor);

    rt_intr_delete(&m_genericIntDescriptor);

    rt_task_delete(&m_genericSrvrDescriptor);

}

 

 

/////////////////////////////////////////

//

// main

//

int main(int argc, char *argv[])

{

    int err = 0;

 

    mlockall(MCL_CURRENT | MCL_FUTURE);

 

    if (argc > 1)

    {

        m_interruptPin = atoi(argv[1]);

        printf("Configuring for pin %d\n", m_interruptPin);

    }

 

    // Create the generic interrupt server as a real-time task

    err = rt_task_create(&m_genericSrvrDescriptor, "GENERIC_PORTG_IRQ_SERVER",

                         INT_STACK_SIZE, INT_PRIORITY, T_JOINABLE);

    if (err < 0)

    {

        printf("ERROR: Could not create task for the interrupt server: %d\n", err);

        return -1;

    }

 

    printf("Interrupt task created\n"); fflush(stdout);

 

    err = rt_task_start(&m_genericSrvrDescriptor, &generic_irq_server, NULL);

    if (err < 0)

    {

        printf("ERROR: Could not start task for the interrupt server: %d\n", err);

        return -1;

    }

 

    printf("...task started\n"); fflush(stdout);

 

    signal(SIGTERM, clean_exit);

    signal(SIGINT, clean_exit);

 

    pause();

 

    fflush(NULL);

    return 0;

}

 

QuoteReplyEditDelete

 

 

2010-05-07 16:22:37     Re: Not receiving interrupts

Mike Frysinger (UNITED STATES)

Message: 89241   

 

i dont see you configuring any edge/level behavior.  it would probably be easier if you generated a square wave on the input pin instead of a solid level.

QuoteReplyEditDelete

 

 

2010-05-07 16:49:11     Re: Not receiving interrupts

Bryan Hilterbrand (UNITED STATES)

Message: 89242   

 

There is a square wave going to the pin - it is normally high and briefly goes low when an A/D converter is finished. I was going to add the code to trigger on falling edge after I saw that the rt_intr_wait was receiving an interrupt. Is this the correct code to add for falling edge?

 

set_irq_type(IRQ_PG0 + m_interruptPin, IRQF_TRIGGER_FALLING);

 

Should this go before or after the rt_intr_create()?

QuoteReplyEditDelete

 

 

2010-05-07 16:55:12     Re: Not receiving interrupts

Mike Frysinger (UNITED STATES)

Message: 89243   

 

you'd have to consult the xenomai documentation for how they manage resources.  i can only tell you how to do it under Linux:

  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:interrupts

QuoteReplyEditDelete

 

 

2010-05-07 17:10:02     Re: Not receiving interrupts

Robin Getz (UNITED STATES)

Message: 89244   

 

Bryan:

 

How "briefly"? ms or us?

 

-Robin

QuoteReplyEditDelete

 

 

2010-05-07 17:21:12     Re: Not receiving interrupts

Bryan Hilterbrand (UNITED STATES)

Message: 89245   

 

"Briefly" is about 40 μs in this case.

Attachments

    Outcomes