[ECOS] Interrupt acknowledge in ISR.

Nick Garnett nickg@redhat.com
Thu Dec 6 04:00:00 GMT 2001

Jonathan Larmour <jlarmour@redhat.com> writes:

> felixwong@i-technologies.cc wrote:
> > 
> > I have just read the "from ISR to thread" messages.  So other issue
> > I'd like to mention.
> > 
> > From eCos CVS, some people put  "cyg_drv_interrupt_acknowledge()" in
> > ISRs, some put it into DSRs, even some others (e.g. edb7xxx) put this
> > line into the threads created by DSR semaphore.
> > 
> > However, should this be commonly put into the ISR routine?  For my
> > hardware (Samsung S3C44B0X), if "cyg_drv_interrupt_acknowledge()"
> > is not put in ISR, the program will interrupt again immediately after
> > the "return cyg_isr_call_dsr" line. DSR and any other threads can NEVER
> > be executed, the MCU is interrupting again and again.  Is this normal?
> You should mask the interrupt in the ISR before returning, and then unmask
> it in the DSR.
> > Is there any ISR design difference in MCUs (in my case all ARM MCU),
> > so that people may put "cyg_drv_interrupt_acknowledge()" even out
> > of the ISR?
> There's no reason why not as long as you don't mind getting another
> interrupt (so you may want to mask it). It's possible that simple interrupt
> controllers won't report any other interrupts until that one is
> acknowledged, so you won't be able to nest interrupts, including
> potentially higher priority ones. So generally it is preferable to
> acknowledge the interrupt as soon as possible, i.e. in the ISR.
> > In my case, if I were to disable interrupts before I finish DSR,
> > I have to put the "cyg_drv_interrupt_unmask()" at the end of DSR only.  The
> > "cyg_drv_interrupt_acknowledge()" is always put in ISR.
> And cyg_drv_interrupt_mask in the ISR too.

This business of masking the interrupt in the ISR and unmasking it in
the DSR is specific to the way the serial drivers are designed. In
general there should be no need to mess with the interrupt mask at
all once the device has been enabled.

The correct approach is for the ISR to do whatever is necessary at the
device to cancel the interrupt condition, and to then call
cyg_drv_interrupt_acknowledge() to cancel it in the interrupt
controller. cyg_drv_interrupt_acknowledge() should *always* be in the
ISR, it is poor practice to put it elsewhere.

Nick Garnett, eCos Kernel Architect
Red Hat, Cambridge, UK

More information about the Ecos-discuss mailing list