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]

eCos interrupt programming (on SA1100)


Hi folks,

I have to do some interrupt action within my application. I wrote a little testing program to get a feeling of eCos interrupt programming and now I'am confused because it doesn't work as expected. What's the magic spell?

Here's what I wrote (please dont't laugh):

--------------------8<----------------------------
#include <pkgconf/kernel.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl>
#include <cyg/kernel/kapi.h>
#include <cyg/io/config_keys.h>

int gCounter = 0;

cyg_ISR_t isrMethod;
cyg_DSR_t dsrMethod;

cyg_thread_entry mainThread;

char gStack0 [4096];
char gBuffer [100];

cyg_uint32 isrMethod ( cyg_vector_t anIntrVector, 
                       cyg_addrword_t aDataAddress) {
  cyg_interrupt_acknowledge ( anIntrVector);
  gCounter++;
  //return CYG_ISR_HANDLED;
  return CYG_ISR_CALL_DSR;
} 

void dsrMethod ( cyg_vector_t anIntrVector, 
                 cyg_ucount32 aCounter,
                 cyg_addrword_t aDataAddress) {
  gCounter++;
  printf ( ">");
}
                     
void mainThread ( cyg_addrword_t pThreadData) {
  cyg_handle_t   lIntrHandle;
  cyg_interrupt  lIntr;
  cyg_vector_t   lIntrVector;
  cyg_priority_t lIntrPriority;
  int lOldCounter = gCounter;
  
  lIntrPriority = 99;
  lIntrVector   = CYGNUM_HAL_INTERRUPT_RTC;

  cyg_interrupt_create ( lIntrVector,
                         lIntrPriority,
                         (cyg_addrword_t) 0,
                         isrMethod,
                         dsrMethod,
                         &lIntrHandle,
                         &lIntr);
  cyg_interrupt_attach ( lIntrHandle);
  
  printf ( "interrupt %i attached ...\n", lIntrVector);

  for ( ;;) {
    if ( ( lOldCounter != gCounter) || 1) {
      printf ( " %i interrupts so far ...\n", gCounter);
      lOldCounter = gCounter;
    }
    Cyg_Thread::self()->delay ( 1);
  }
}

#ifdef __cplusplus
extern "C" {
#endif

void cyg_user_start ( void) {
//int main () {
  Cyg_Thread* lThread0;
  char* lPing = "ping";
  int lError;
	
  lThread0 = new Cyg_Thread ( CYG_SCHED_DEFAULT_INFO,
                              mainThread,
                              (cyg_addrword_t) lPing,
                              NULL,
                              (cyg_addrword_t) gStack0,
                              4096);
  printf ( "thread0 created ...\n");
  
  cyg_interrupt_enable ();
  lThread0->resume ();
  printf ( "thread0 resumed ...\n"); 
}
#ifdef __cplusplus
}
#endif

------------------>8------------------------

As you see I want to catch the timer interrupt just for the fun. But the ISR never gets called, the counter-variable stays at zero.

I'm using a sligthly modified brutus-port (no interrupt stuff touched) and the current CVS version of eCos. 

-- 
-----------------------------------------------------
i.A. Andreas Bürgel     GenoLogic GmbH
     Software Engineer  Joseph-von-Fraunhofer-Str. 13
                        D-44227 DORTMUND
                        Germany               
                        
     ab@genologic.de    phone  +49 (0) 231/477349-0
                        fax    +49 (0) 231/4761234

______________________________________________________________________________
Ferienklick.de - Jede Menge Urlaub auf einen Blick!
Hier geht's zu Ihrem Traumstrand: http://ferienklick.de/?PP=2-0-100-105-1


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