This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: AW: AW: help needed: interrupt + semaphore


On Tue, 2002-08-20 at 06:18, Edelmann Thomas wrote:
> Hi,
> 
> I've tried this, but, Sorry, it didn't help.
> 

Did you still have the "enable_interrupts()" call in there?   That would
certainly mess things up.

> Only the ISR ...

After the ISR runs, you should be able to stop in the scheduler and see
what it's doing when it goes to run the DSRs.  Use GDB - it is your
friend :-)

> 
> Thanks for your Help,
> Thomas
> 
> 
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Gary Thomas [mailto:gthomas@ecoscentric.com]
> > Gesendet: Dienstag, 20. August 2002 14:07
> > An: Edelmann Thomas
> > Cc: 'Robert Cragie'; eCos Discussion; thomas.edelmann@gmx.de
> > Betreff: Re: AW: [ECOS] help needed: interrupt + semaphore
> > 
> > 
> > On Tue, 2002-08-20 at 04:56, Edelmann Thomas wrote:
> > > Hi,
> > > 
> > > thanks for your help! 
> > > 
> > > But this doesn't solve the problem. The ISR is always 
> > called, but then
> > > nothing happens, no DSR, no INTThread.
> > > 
> > > Knows someone something else?
> > > 
> > 
> > You need to start the scheduler, otherwise nothing else will
> > happen - the threads won't run and the DSR will never be called.
> > 
> > There are more comments below, in your code.
> > 
> > > bye, Thomas
> > > 
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: Robert Cragie [mailto:rcc@jennic.com]
> > > > Gesendet: Dienstag, 20. August 2002 12:07
> > > > An: Edelmann Thomas; ecos-discuss@sources.redhat.com
> > > > Cc: thomas.edelmann@gmx.de
> > > > Betreff: RE: [ECOS] help needed: interrupt + semaphore
> > > > 
> > > > 
> > > > I do it like this and it works for me:
> > > > 
> > > > static cyg_uint32 intE1ISR(cyg_vector_t vector, 
> > cyg_addrword_t data)
> > > > {
> > > > 	cyg_interrupt_mask(vector);
> > > > 
> > > > 	cyg_interrupt_acknowledge(vector);
> > > > 
> > > > 	return CYG_ISR_CALL_DSR;
> > > > }
> > > > 
> > > > static void intDSR(cyg_vector_t vector, cyg_ucount32 count, 
> > > > cyg_addrword_t
> > > > data)
> > > > {
> > > >     cyg_semaphore_post(&semEINT1);
> > > > 
> > > >     cyg_interrupt_unmask(vector);
> > > > }
> > > > 
> > > > I also commented that cyg_interrupt_acknowledge() must be 
> > > > called in the
> > > > ISR - the docs. seem to say this must be done.
> > > > 
> > > > HTH
> > > > 
> > > > Robert Cragie, Design Engineer
> > > > ________________________________________________________
> > > > Jennic Ltd, Furnival Street, Sheffield, S1 4QT,  UK
> > > > www.jennic.com Tel: +44 (0) 114 281 2655
> > > > 
> > > > > -----Original Message-----
> > > > > From: ecos-discuss-owner@sources.redhat.com
> > > > > [mailto:ecos-discuss-owner@sources.redhat.com]On Behalf 
> > Of Edelmann
> > > > > Thomas
> > > > > Sent: 20 August 2002 08:44
> > > > > To: 'ecos-discuss@sources.redhat.com'
> > > > > Cc: 'thomas.edelmann@gmx.de'
> > > > > Subject: [ECOS] help needed: interrupt + semaphore
> > > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > > I need your help! I've attached a simplified copy of my System.
> > > > > Only running
> > > > > an Interrupthandler with a Semaphore.
> > > > >
> > > > > But it is not running. The Problem: If I receive an 
> > > > external Interupt
> > > > > (created by a FPGA) the ISR Routine is called, but nothing 
> > > > else. WHY???
> > > > >
> > > > > What am I doing wrong???
> > > > >
> > > > > Thanks for your Help!
> > > > >
> > > > > bye,
> > > > > Thomas
> > > > >
> > > > >
> > > > > --- System.c ---
> > > > >
> > > > > #include <stdio.h>                      /* printf */
> > > > > #include <stdlib.h>
> > > > > #include <pkgconf/system.h>
> > > > > #include <pkgconf/net.h>
> > > > > #include <pkgconf/posix.h>
> > > > > #include <pkgconf/kernel.h>
> > > > > #include <fcntl.h>
> > > > > #include <mqueue.h>
> > > > > #include <cyg/kernel/kapi.h>            /* All the kernel
> > > > > specific stuff */
> > > > > #include <cyg/io/io.h>                  /* I/O functions */
> > > > > #include <cyg/hal/hal_arch.h>           /*
> > > > > CYGNUM_HAL_STACK_SIZE_TYPICAL */
> > > > > #include <cyg/hal/hal_intr.h>
> > > > > #include <cyg/hal/hal_edb7xxx.h>
> > > > > #include <network.h>
> > > > >
> > > > > /* ============ */
> > > > > /* === ecos === */
> > > > >
> > > > > /* DEFINES */
> > > > >
> > > > > #define NTHREADS 2
> > > > > #define STACKSIZE ( CYGNUM_HAL_STACK_SIZE_TYPICAL)
> > > > >
> > > > > /* STATICS */
> > > > >
> > > > > static cyg_handle_t		thread[NTHREADS];
> > > > > static cyg_thread			thread_obj[NTHREADS];
> > > > > static char				
> > stack[NTHREADS][STACKSIZE];
> > > > >
> > > > > static cyg_handle_t		hEInt1;
> > > > > static cyg_interrupt		iEInt1;
> > > > > static cyg_sem_t			semEINT1;
> > > > >
> > > > > static void intDSR(cyg_vector_t vector, cyg_ucount32 count, 
> > > > cyg_addrword_t
> > > > > data)
> > > > > {
> > > > > 	cyg_semaphore_post(&semEINT1);
> > > > > }
> > > > >
> > > > > static cyg_uint32 intE1ISR(cyg_vector_t vector, 
> > cyg_addrword_t data)
> > > > > {
> > > > > 	cyg_interrupt_mask(CYGNUM_HAL_INTERRUPT_EINT1);
> > > > >
> > > > > 	return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR);  // 
> > Run the DSR
> > > > > }
> > > > >
> > > > > void INTThread (CYG_ADDRESS data)
> > > > > {
> > > > > 	while (1)
> > > > > 	{
> > > > > 		cyg_semaphore_wait(&semEINT1);
> > > > >
> > > > > 		diag_printf("INTThread: IRT IRQ1: %.8lX 
> > NRT IRQ1:
> > > > > %.8lX\n\n", IO_SP_IRQ1_IRT, IO_SP_IRQ1_NRT);
> > > > >
> > > > > 		
> > cyg_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_EINT1);
> > > > > 		
> > cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_EINT1);
> > > > > 	}
> > > > > }
> > > > >
> > > > > externC void
> > > > > cyg_user_start( void )
> > > > > {
> > > > > 	cyg_semaphore_init(&semEINT1, 0);
> > > > >
> > > > > 	cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_EINT1,
> > > > > 		6,                     // Priority - unused
> > > > > 		1,   //  Data item passed to interrupt handler
> > > > > 		intE1ISR,
> > > > > 		intDSR,
> > > > > 		&hEInt1,
> > > > > 		&iEInt1);
> > > > >
> > > > > 	cyg_interrupt_attach(hEInt1);
> > > > > 	cyg_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_EINT1);
> > > > >
> > > > > 	// Interrupt Freigabe
> > > > > 	cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_EINT1);
> > > > >
> > > > > 	// Interrupts aktivieren
> > > > > 	// external 1
> > > > > 	*(volatile unsigned char *)INTMR1 |= 0x20;
> > > > >
> > > > > 	cyg_interrupt_enable();
> >         ^^^^^^^^^^^^^^^^^^^^^^^
> > 
> > Don't do this!  It's done by cyg_scheduler_start(), only when 
> > it's safe
> > to do so.
> > 
> > > > >
> > > > > 	cyg_thread_create (5, INTThread, (cyg_addrword_t) 0, 
> > > > "INTThread",
> > > > > 		(void *)stack[5], STACKSIZE, &thread[5], 
> > > > &thread_obj[5]);
> > > > > 	cyg_thread_resume (thread[5]);
> > > > >
> > > > > //	cyg_scheduler_start();
> >                 ^^^^^^^^^^^^^^^^^^^^^^
> > 
> > This must be called for this program to function.
> > 
> > > > > }
> > > > >
> > > > > --- \System.c ---
> > > > >
> > > > > Mit freundlichen Grüßen
> > > > > Thomas Edelmann
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Before posting, please read the FAQ: 
> > > http://sources.redhat.com/fom/ecos
> > > > and search the list archive: 
> > http://sources.redhat.com/ml/ecos-discuss
> > > >
> > > >
> > > 
> > > -- 
> > > Before posting, please read the FAQ: 
> > http://sources.redhat.com/fom/ecos
> > > and search the list archive: 
> > http://sources.redhat.com/ml/ecos-discuss
> > 
> > -- 
> > ------------------------------------------------------------
> > Gary Thomas                  |
> > eCosCentric, Ltd.            |  
> > +1 (970) 229-1963            |  eCos & RedBoot experts
> > gthomas@ecoscentric.com      |
> > http://www.ecoscentric.com/  |
> > ------------------------------------------------------------
> > 
> 
> -- 
> Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
> and search the list archive: http://sources.redhat.com/ml/ecos-discuss
-- 
------------------------------------------------------------
Gary Thomas                  |
eCosCentric, Ltd.            |  
+1 (970) 229-1963            |  eCos & RedBoot experts
gthomas@ecoscentric.com      |
http://www.ecoscentric.com/  |
------------------------------------------------------------


--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]