RTAI Interript Problem

Usman S. Ansari uansari at yahoo.com
Thu Aug 1 18:40:03 CEST 2002


Thanks to all of those who replied.

Initially, I was trying to rt_enable_irq in the ISR itself, but this turn out to be a bad idea,
since it locks up the system.

Follwoing suggestion by some of you, I have a bottom half, which I am only using it to enable the
interrupt after ISR is done. My ISR curretly is only  3 lines of code + 3 rt_printks.

So, my init_module, beside registering irq and eanabling it, does following
static RT_TASK     rtai_bh;
int init_module (void)
{
 .
 .
 .
  rt_task_init(&rtai_bh, rtai_bottom_half, 0, 2000, 5, 0, 0);
  rt_task_resume(&rtai_bh);
  .
  .
}

My bottom half

static void rtai_bottom_half(int t)
{
 while (1)
    {
     rt_printk("bottom half waiting for siganl\n");
     rt_sleep(5);
rt_printk("*** before suspend ***\n");
     rt_task_suspend(rt_whoami());
rt_printk("*** before suspend ***\n");
     rt_printk("bottom half enabling interrupt\n");
     rt_enable_irq(HUDSON_INTR_NUMBER);
    }
}

I see the 
bottom half waiting for siganl
line printed in the syslog and never see 

*** before suspend ***
printed

and it never pass rt_task_suspend line.

In my ISR, 

static void hudson_intr(void)
{
 UINT16  control_1;

 printk("*** entering hudson ISR ***\n");
 control_1 = HB_HDSN_IRQ_STAT;
 HB_HDSN_IRQ_LCK = HUDSON_IRQ_RESET;

printk("*** before resume ***\n");
rt_task_resume(&rtai_bh);
printk("*** after resume ***\n");

 return;
}

I see both 

*** before resume ***\n
*** after resume ***

lines printed. Can you tell me what I am doing wrong, please ?

Usman
--- Wolfgang Grandegger <wolfgang.grandegger at bluewin.ch> wrote:
> Hello,
> 
> you have to reenable the interrupt "manually" in your handler
> with rt_enable_irq(). This is different to Linux.
> 
> Here are some further remarks about interrupt handling in RTAI.
> While the RTAI interrupt handler runs, interrupts are disabled globally.
> Therefore the ISR should be very short (just a few lines of code) and
> you should delegate most of (all) the work for the interrupt handling to
> RTAI tasks. Typically one use rt_resume_task in the ISR. When the
> interrupt is handled by the task it should call rt_enable_irq() to reenable
> that interrupt source when appropriate.
> 
> Hope it helps.
> 
> Wolfgang.
> 
> PS: I recommend to use RTAI from the CVS repository because it has
> various bugs fixed. You can keep your kernel patch from DENX RTAI 24.1.8.
> 
> 
> 
> On 07/31/2002 09:30 PM, Usman S. Ansari wrote:
> 
> >I am not sure, if first time this mail made it to the list.
> >
> >I am developing my embedded system software on PPC 8xx, running Linux 2.4.4-rthal5. RTAI
> version
> >is rtai-24.1.8.
> >
> >I have a rtai interrupt handler, which wakes up first time interrupt occurs after I install the
> >module. But on any subsequent interrupts the handler is not invoked. I debugged and found that
> >global_irq[irq].handler == 0 on /* line # 514 on arch/ppc/rtai.c */. i.e. the pointer to the
> >handler function is erased ***SOME HOW***. I have not been able to figure out why. 
> >
> >My hadler looks like:
> >
> >static void hudson_intr(void)
> >{
> > rt_printk("*** entering hudson ISR ***\n");
> > return;
> >}
> >
> >int init_module (void)
> >{
> > rt_printk("init_module called\n");
> >
> > /* map register area, for Linux kernel */ 
> > cio_map_hudsons = ioremap(OCR_REG_BASE, OCR_MAP_LENGTH);
> >
> > /* installed interrupt handler */
> > if (rt_request_global_irq(HUDSON_INTR_NUMBER, (void *) hudson_intr) != 0)
> >    {
> >     rt_printk("hudson_intr: unable to install interrupt handler for hudson\n");
> >     return(-EIO);
> >    }
> >
> > rt_enable_irq(HUDSON_INTR_NUMBER);
> >
> > rt_printk("hudson_intr: hudson interrupt handler driver installed\n");
> > return(0);
> >}
> >
> >void cleanup_module (void)
> >{
> > rt_printk("cleanup_module called\n");
> >
> > rt_disable_irq(HUDSON_INTR_NUMBER);
> >
> > if (rt_free_global_irq(HUDSON_INTR_NUMBER) < 0)
> >    rt_printk("hudson_intr: unable to free irq\n");
> >
> > /* unmap register area */
> > iounmap(OCR_REG_BASE);
> >
> > rt_printk ("hudson_intr: hudson interrupt handler driver uninstalled\n");
> >}
> >
> >Please help, I am stuck on this for couple of days. Also, please cc me on the reply as I am not
> >sure I am getting the list mail.
> >
> >Thanks
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Yahoo! Health - Feel better, live better
> >http://health.yahoo.com
> >
> >_______________________________________________
> >RTAI mailing list
> >RTAI at rtai.org
> >https://mail.rtai.org/cgi-bin/mailman/listinfo/rtai
> >
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com




More information about the Rtai mailing list