This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Help! Program stops recognizing IRQ2 interrupts
- From: Giri Raja <giri_amf at yahoo dot com>
- To: ecos-discuss at ecos dot sourceware dot org
- Date: Thu, 22 Apr 2004 15:20:14 -0700 (PDT)
- Subject: [ECOS] Help! Program stops recognizing IRQ2 interrupts
Hi,
I have written a small program that looks for the
IRQ2 interrupt, and posts a semaphore on that event.
The IRQ2 interrupt is triggered externally every 1.5
ms. I'm able to catch the interrupts for about 1-2
secs and after that my program just stops working.
Currently I'm using GDB to monitor this activity.
Here is the code that I'm using.
*********************************************
include <cyg/kernel/kapi.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <cyg/hal/hal_arch.h>
static cyg_interrupt int1;
static cyg_handle_t int1_handle;
static cyg_sem_t data_ready;
// thread specific stuff
cyg_thread thread_s;
char stack_size[4096];
cyg_thread_entry_t read_fifo;
cyg_handle_t fifo_thread;
#define CYGNUM_HAL_INTERRUPT_1 18
#define CYGNUM_HAL_PRI_HIGH 0
// the ISR routine
cyg_uint32 interrupt_1_isr(cyg_vector_t vector,
cyg_addrword_t data) {
// mask it from further such interrupts
cyg_interrupt_mask(vector);
// acknowledge
cyg_interrupt_acknowledge(vector);
// hand over to DSR
return(CYG_ISR_HANDLED | CYG_ISR_CALL_DSR);
}
// the DSR routine
void interrupt_1_dsr(cyg_vector_t vector, cyg_ucount32
count, cyg_addrword_t data) {
// call your own stuff here
// post a semaphore for the time being
cyg_semaphore_post(&data_ready);
// unmask and allow further interrupts
cyg_interrupt_unmask(vector);
}
// the main program
void cyg_user_start(void) {
cyg_vector_t int1_vector =
CYGNUM_HAL_INTERRUPT_1;
cyg_priority_t int1_priority =
CYGNUM_HAL_PRI_HIGH;
// initialize the semaphore with value 0
// post increments by one and wait decrements
by one
cyg_semaphore_init(&data_ready, 0);
// create the interrupt
cyg_interrupt_create(
int1_vector,
int1_priority,
0,
&interrupt_1_isr,
&interrupt_1_dsr,
&int1_handle,
&int1);
// attach the interrupt to the vector
cyg_interrupt_attach(int1_handle);
// unmask the interrupt
cyg_interrupt_unmask(int1_vector);
// now create the fifo thread
cyg_thread_create(
4,
read_fifo,
(cyg_addrword_t) 0,
"FIFO THREAD",
(void *) stack_size,
4096,
&fifo_thread,
&thread_s);
// the main program
void cyg_user_start(void) {
cyg_vector_t int1_vector =
CYGNUM_HAL_INTERRUPT_1;
cyg_priority_t int1_priority =
CYGNUM_HAL_PRI_HIGH;
// initialize the semaphore with value 0
// post increments by one and wait decrements
by one
cyg_semaphore_init(&data_ready, 0);
// create the interrupt
cyg_interrupt_create(
int1_vector,
int1_priority,
0,
&interrupt_1_isr,
&interrupt_1_dsr,
&int1_handle,
&int1);
// attach the interrupt to the vector
cyg_interrupt_attach(int1_handle);
// unmask the interrupt
cyg_interrupt_unmask(int1_vector);
// now create the fifo thread
cyg_thread_create(
4,
read_fifo,
(cyg_addrword_t) 0,
"FIFO THREAD",
(void *) stack_size,
4096,
&fifo_thread,
&thread_s);
// resume the thread when the scheduler starts
cyg_thread_resume(fifo_thread);
}
void read_fifo(cyg_addrword_t data) {
unsigned chunk_number = 0;
// on an infinite loop print the stuff
for(;;) {
cyg_semaphore_wait(&data_ready);
chunk_number++;
printf("chunk is %d\n", chunk_number);
}
}
*******************************************
Can someone help me out in this.
Thanks.
Giri.
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
http://photos.yahoo.com/ph/print_splash
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss