Skip to contentSkip to conversation

rt_intr_wait

Xenomai-help Wayne Call 2 participants 2 messages Apr 27, 2009 – Apr 28, 2009

lore
Share & tools
lore

Wayne Call

author
#0 lore raw

The code below attempts to process an interrupt in user space. The IRQ is set at 26, and this interrupt fires at once per second. If the rt_intr_create sets the mode to I_NOAUTOENA, the rt_intr_wait detects one interrupt, and then no other interrupts are detected. Likewise for if the mode is set to I_PROPAGATE. If the mode is set to 0, it appears that the rt_intr_wait detects interrupts at a very high rate, possible thousands per second. It appears that the code is detecting some other interrupt, and not the IRQ at 26.

Below is the irq file and stat file for when the mode is set to I_NOAUTOENA or I_PROPAGATE.

Is there a step that I'm missing to get the rt_intr_wait to recognize the correct IRQ?

Wayne

//

// pwm_precon.c

//

#include <sys/mman.h>

#include <signal.h>

#include <native/task.h>

#include <native/intr.h>

#include <stdio.h>

#define COMPILE_LPL_DEBUG 1

#include "../lplLib/lplDebug.h"

#define LPL_PWM_PRECON_IRQ_NUMBER 26

#define LPL_PWM_PRECON_TASK_PRIO 99

#define LPL_PWM_PRECON_TASK_MODE 0

#define LPL_PWM_PRECON_TASK_STKSZ 0

RT_INTR m_interruptDescriptor;

RT_TASK m_serverDescriptor;

long int m_isrCounter = 0;

void cleanup(int sig);

void lpl_pwm_precon_irq_server(void *cookie)

{

    int err;

 

    for (;;) 

    {

        // Wait for next interrupt

        err = rt_intr_wait(&m_interruptDescriptor, TM_INFINITE);

        if (err > 0) 

        {

            LPL_DEBUG("process interrupt", m_isrCounter, %d); 

        }

        m_isrCounter++;

        LPL_DEBUG("isr real-time interrupt", err, %d); 

    }

}

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

{

    int err = 0;

    int bfinTimerStatus;

 

    mlockall(MCL_CURRENT | MCL_FUTURE);

    err = rt_intr_create(&m_interruptDescriptor, "PWM_PRECON_IRQ",

LPL_PWM_PRECON_IRQ_NUMBER, I_NOAUTOENA);

// err = rt_intr_create(&m_interruptDescriptor, "PWM_PRECON_IRQ",
LPL_PWM_PRECON_IRQ_NUMBER, I_PROPAGATE);

// err = rt_intr_create(&m_interruptDescriptor, "PWM_PRECON_IRQ",
LPL_PWM_PRECON_IRQ_NUMBER, 0);

LPL_DEBUG("create real-time interrupt", err, %d);

err = rt_task_create(&m_serverDescriptor, "PWM_PRECON_IRQ_SERVER",
LPL_PWM_PRECON_TASK_STKSZ,

LPL_PWM_PRECON_TASK_PRIO,
LPL_PWM_PRECON_TASK_MODE);

    LPL_DEBUG("create real-time task", err, %d); 

    if (!err) 

    {

        rt_task_start(&m_serverDescriptor, &lpl_pwm_precon_irq_server,

NULL);

        LPL_DEBUG("start real-time task", err, %d);

        rt_intr_enable(&m_interruptDescriptor); 

        LPL_DEBUG("enable real-time interrupt", err, %d);

    }

 

    signal(SIGTERM, cleanup);

    signal(SIGINT, cleanup);

 

    pause();

 

    fflush(NULL);

}

void cleanup(int sig)

{

    int err = 0;

 

    rt_intr_disable(&m_interruptDescriptor); 

    LPL_DEBUG("disable real-time interrupt", err, %d); 

    rt_intr_delete(&m_interruptDescriptor);

    LPL_DEBUG("delete real-time interrupt", err, %d); 

    rt_task_delete(&m_serverDescriptor);

    LPL_DEBUG("delete real-time task", err, %d); 

}

#1 lore raw
Quoted 4 lines · Wayne Call

The code below attempts to process an interrupt in user space. The IRQ is set at 26, and this interrupt fires at once per second. If the rt_intr_create sets the mode to I_NOAUTOENA, the rt_intr_wait detects one interrupt, and then no other interrupts are detected.

Doing so, you tell the Xenomai core not to re-enable the handled interrupt channel when your ISR has returned, so it expects you do that on your side when your code sees it fit, by calling rt_intr_enable().

Quoted 1 line

Likewise for if the mode is set to I_PROPAGATE.

This mode implies no-enable as well, since it tells the Xenomai core to progagate the interrupt notification down to the Linux kernel, and expects the latter to re-enable the channel when it is done with handling the IRQ.

Quoted 5 lines

If the mode is set to 0, it appears that the rt_intr_wait detects
interrupts at a very high rate, possible thousands per second. It appears that the code is detecting some other interrupt, and not the IRQ at 26.

This can't be. I would rather suspect a level sense interrupt storming your board because your handler did not clear the interrupt properly.

Quoted 215 lines

Below is the irq file and stat file for when the mode is set to I_NOAUTOENA or I_PROPAGATE.

Is there a step that I’m missing to get the rt_intr_wait to recognize the correct IRQ?

Wayne

//

// pwm_precon.c

//

#include <sys/mman.h>

#include <signal.h>

#include <native/task.h>

#include <native/intr.h>

#include <stdio.h>

#defineCOMPILE_LPL_DEBUG 1

#include "../lplLib/lplDebug.h"

#defineLPL_PWM_PRECON_IRQ_NUMBER 26

#defineLPL_PWM_PRECON_TASK_PRIO 99

#defineLPL_PWM_PRECON_TASK_MODE 0

#defineLPL_PWM_PRECON_TASK_STKSZ 0

RT_INTR m_interruptDescriptor;

RT_TASK m_serverDescriptor;

long int m_isrCounter = 0;

void cleanup(int sig);

void lpl_pwm_precon_irq_server(void *cookie)

{

    int err;

 

    for (;;) 

    {

       // Wait for next interrupt

        err = rt_intr_wait(&m_interruptDescriptor, TM_INFINITE);

       if (err > 0) 

       {

            LPL_DEBUG("process interrupt", m_isrCounter, %d); 

       }

        m_isrCounter++;

        LPL_DEBUG("isr real-time interrupt", err, %d); 

    }

}

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

{

    int err = 0;

    intbfinTimerStatus;

 

    mlockall(MCL_CURRENT | MCL_FUTURE);

    err = rt_intr_create(&m_interruptDescriptor,"PWM_PRECON_IRQ",

LPL_PWM_PRECON_IRQ_NUMBER, I_NOAUTOENA);

// err = rt_intr_create(&m_interruptDescriptor, "PWM_PRECON_IRQ",
LPL_PWM_PRECON_IRQ_NUMBER, I_PROPAGATE);

// err = rt_intr_create(&m_interruptDescriptor, "PWM_PRECON_IRQ",
LPL_PWM_PRECON_IRQ_NUMBER, 0);

LPL_DEBUG("create real-time interrupt", err, %d);

err = rt_task_create(&m_serverDescriptor,"PWM_PRECON_IRQ_SERVER",
LPL_PWM_PRECON_TASK_STKSZ,

LPL_PWM_PRECON_TASK_PRIO,
LPL_PWM_PRECON_TASK_MODE);

    LPL_DEBUG("create real-time task", err, %d); 

    if (!err) 

    {

        rt_task_start(&m_serverDescriptor, &lpl_pwm_precon_irq_server,

NULL);

        LPL_DEBUG("start real-time task", err, %d);

        rt_intr_enable(&m_interruptDescriptor); 

        LPL_DEBUG("enable real-time interrupt", err, %d);

    }

 

    signal(SIGTERM, cleanup);

    signal(SIGINT, cleanup);

 

    pause();

 

    fflush(NULL);

}

void cleanup(int sig)

{

    int err = 0;

 

    rt_intr_disable(&m_interruptDescriptor); 

    LPL_DEBUG("disable real-time interrupt", err, %d); 

    rt_intr_delete(&m_interruptDescriptor);

    LPL_DEBUG("delete real-time interrupt", err, %d); 

    rt_task_delete(&m_serverDescriptor);

    LPL_DEBUG("delete real-time task", err, %d); 

}

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.