This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Problem with interrupts
- From: "Igor Trevisan" <igor dot trevisan at bluewind dot it>
- To: ecos-discuss at sources dot redhat dot com
- Date: Thu, 31 Jan 2002 12:21:40 +0100
- Subject: [ECOS] Problem with interrupts
Hi all!
I'm having some problems trying to install an interrupt in eCos
program.
I read something in some mails in the present mailing-list
and I also found some code to take as an example.
But I couldn't make it run successfully!!
In the following lines I write the code I'm currently working on and
the output it produces while running on a board derived
from EDB7209 (with an ARM core based processor).
Can anyone explain me why I don't see anything changed by
the ISR?
Why cannot I have interrupts successfully installed?
Thanks in advance...
########################################################
#include <cyg/kernel/kapi.h>
#include <stdio.h>
static volatile unsigned long n_timer_0_interrupts = 0;
static volatile unsigned long n_timer_1_interrupts = 0;
unsigned long pippo = 0;
/* this is the ISR for timer 0 interrupts */
cyg_uint32 timer_0_handler(cyg_vector_t vector, cyg_addrword_t data)
{
/* keep track of how many times that timer has interrupted us; this
is basically all we do in this "driver" */
n_timer_0_interrupts+=1;
/* ISRs must acknowledge the interrupt, or they might be invoked
again */
pippo=13;
cyg_interrupt_acknowledge(vector);
return CYG_ISR_HANDLED;
}
/* this is the ISR for timer 1 interrupts */
cyg_uint32 timer_1_handler(cyg_vector_t vector, cyg_addrword_t data)
{
/* keep track of how many times that timer has interrupted us; this
is basically all we do in this "driver" */
n_timer_1_interrupts+=1;
/* ISRs must acknowledge the interrupt, or they might be invoked
again */
pippo=13;
cyg_interrupt_acknowledge(vector);
return CYG_ISR_HANDLED;
}
/* the main program here sits in an infinite loop seeing if
n_timer_0_interrupts has changed, and printing the new values if it
has changed */
int main( int argc, char *argv[] )
{
int i;
cyg_handle_t timer_0_ISR_H;
cyg_handle_t timer_1_ISR_H;
cyg_interrupt intr0, intr1;
unsigned long previous_timer_0_count = 0;
unsigned long previous_timer_1_count = 0;
printf("\n********** Entered main prog *******************\n");
/* create an interrupt handler with timer_0_handler() as the ISR
and no DSR. A DSR is not needed here because the ISR simply
increments a global variable and does not take much time or use
any operating system services */
cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_RTC, 0, 0, &timer_0_handler,
NULL, &timer_0_ISR_H, &intr0);
// cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_TC1OI, 0, 0, &timer_1_handler,
// NULL, &timer_1_ISR_H, &intr1);
printf("********** Created interrupts handlers *********\n");
cyg_interrupt_attach(timer_0_ISR_H);
// cyg_interrupt_attach(timer_1_ISR_H);
cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_RTC);
cyg_interrupt_enable();
printf("********** Started main loop *******************\n");
for (i=0;;i++) {
if(i%10000000==0)
printf("%d°loop\n",i);
if(pippo==13)
{
printf("Yeeee!!!!.............\n");
pippo=0;
}
if (n_timer_0_interrupts != previous_timer_0_count) {
printf("new value of n_timer_0_interrupts: %lu\n",
n_timer_0_interrupts);
previous_timer_0_count = n_timer_0_interrupts;
}
if (n_timer_1_interrupts != previous_timer_1_count) {
printf("new value of n_timer_1_interrupts: %lu\n",
n_timer_1_interrupts);
previous_timer_1_count = n_timer_1_interrupts;
}
}
}
#################### OUTPUT #########################
********** Entered main prog *******************
********** Created interrupts handlers *********
********** Started main loop *******************
0°loop
10000000°loop
20000000°loop
#####################################################
-----------------------------------------------------------------
BlueWind Embedded Systems Design
Via Steffani 7/B
31033 Castelfranco Veneto (TV)
-----------------------------------------------------------------
Office +39 0 423 723431
Fax +39 0 423 744738
Mobile +39 335 7298820
mailto:igor.trevisan@bluewind.it
http://www.bluewind.it
----------------------------------------------