Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Interruption: (4 Items)
   
Interruption  
I'm trying to use the interruption and I would liko to know how do it using the edge. That's my code:
 
 
struct sigevent event;
void* int_thread (void *arg);
const struct sigevent * isr_handler (void *arg, int id);
int var=0;

int main(int argc, char *argv[]) {
 
    event.sigev_notify = SIGEV_INTR;
  
    while(1){
 
        pthread_create (NULL, NULL, int_thread, NULL);
 
        delay(1000);
    }
}

const struct sigevent * isr_handler (void *arg, int id) {
    var ++;
    return (&event);
}
 
void* int_thread (void *arg) 
{
  int errvalue, erroWait, valor;
 
  ThreadCtl (_NTO_TCTL_IO, NULL); // enable I/O privilege
 
  InterruptAttach(0xE,isr_handler,NULL,0,_NTO_INTR_FLAGS_TRK_MSK);
  //InterruptAttachEvent(0xE,&event,_NTO_INTR_FLAGS_TRK_MSK);
 
  //errvalue = errno;
  //printf("Erro: %s\n", strerror(errvalue));
 
  while (1) 
  { 
        InterruptWait (NULL, NULL);
  
        erroWait=errno;
        printf("erroWait=%s %d\n", strerror(erroWait),var);
  
  } 
}
 
 
I'm doing the interruption on IRQ15, but when I run this code, it interrupts alone, without doing anything. 
Thanks.


(Sorry about my english.)
RE: Interruption  

> -----Original Message-----
> From: Diogo Dias [mailto:community-noreply@qnx.com]
> Sent: February-17-09 11:50 AM
> To: momentics-community
> Subject: Interruption
> 
> I'm trying to use the interruption and I would liko to know how do it
> using the edge. That's my code:
> 
> 
> struct sigevent event;
> void* int_thread (void *arg);
> const struct sigevent * isr_handler (void *arg, int id);
> int var=0;
> 
> int main(int argc, char *argv[]) {
> 

Use SIGEV_INTR_INIT( &event ) instead, although what you did is ok.

>     event.sigev_notify = SIGEV_INTR;
> 
>     while(1){
> 
>         pthread_create (NULL, NULL, int_thread, NULL);

// Check the return value 
> 
>         delay(1000);
>     }
> }

This will create a thread every second, is that intended?

> 
> const struct sigevent * isr_handler (void *arg, int id) {
>     var ++;
>     return (&event);
> }
> 
> void* int_thread (void *arg)
> {
>   int errvalue, erroWait, valor;
> 
>   ThreadCtl (_NTO_TCTL_IO, NULL); // enable I/O privilege
> 
>   InterruptAttach(0xE,isr_handler,NULL,0,_NTO_INTR_FLAGS_TRK_MSK);
>   //InterruptAttachEvent(0xE,&event,_NTO_INTR_FLAGS_TRK_MSK);
> 
>   //errvalue = errno;
>   //printf("Erro: %s\n", strerror(errvalue));
> 
>   while (1)
>   {
>         InterruptWait (NULL, NULL);
> 
>         erroWait=errno;
>         printf("erroWait=%s %d\n", strerror(erroWait),var);
> 
>   }
> }
> 
> 
> I'm doing the interruption on IRQ15, but when I run this code, it
> interrupts alone, without doing anything.

Are you sure the hardware interrupt is generated?  

> Thanks.
> 
> 
> (Sorry about my english.)
> 
> _______________________________________________
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post22359
> 
Re: RE: Interruption  
Yes, I'm sure. Returns it:

erroWait=No error 1
erroWait=No error 7
erroWait=No error 8
erroWait=No error 9
erroWait=No error 10
erroWait=No error 13
erroWait=No error 14
erroWait=No error 15
erroWait=No error 16
erroWait=No error 17
erroWait=No error 18
erroWait=No error 19
erroWait=No error 20
erroWait=No error 21
erroWait=No error 22
erroWait=No error 23
erroWait=No error 25
erroWait=No error 27
erroWait=No error 27
erroWait=No error 27
erroWait=No error 29
erroWait=No error 29
erroWait=No error 33
erroWait=No error 37
erroWait=No error 37
erroWait=No error 37
erroWait=No error 37
erroWait=No error 37
erroWait=No error 37
erroWait=No error 37


The number is the "var"
That means it's interrupting, isn't? 
______________________________________________________



And about the edge? How can I use the interruption by edge?
RE: RE: Interruption  

> -----Original Message-----
> From: Diogo Dias [mailto:community-noreply@qnx.com]
> Sent: February-17-09 1:00 PM
> To: momentics-community
> Subject: Re: RE: Interruption
> 
> Yes, I'm sure. Returns it:
> 
> erroWait=No error 1
> erroWait=No error 7
> erroWait=No error 8
> erroWait=No error 9
> erroWait=No error 10
> erroWait=No error 13
> erroWait=No error 14
> erroWait=No error 15
> erroWait=No error 16
> erroWait=No error 17
> erroWait=No error 18
> erroWait=No error 19
> erroWait=No error 20
> erroWait=No error 21
> erroWait=No error 22
> erroWait=No error 23
> erroWait=No error 25
> erroWait=No error 27
> erroWait=No error 27
> erroWait=No error 27
> erroWait=No error 29
> erroWait=No error 29
> erroWait=No error 33
> erroWait=No error 37
> erroWait=No error 37
> erroWait=No error 37
> erroWait=No error 37
> erroWait=No error 37
> erroWait=No error 37
> erroWait=No error 37
> 
> 
> The number is the "var"
> That means it's interrupting, isn't?

Seems like it.  Note that errno is only valid if InterruptWait returns -1.  What I mean is that errno is NOT set to EOK 
when there are no error, you code could well show an error code when there isn't any error

	if( InterruptWait (NULL, NULL) == -1 )
	{
		erroWait=errno;
      	printf("erroWait=%s ", strerror(erroWait));
	}
	printf("Val %d\n", val );

The fact that you have strange value for "var" is probably because there are more than one instance of the interrupt 
thread.  

  
> And about the edge? How can I use the interruption by edge?

That depends on the hardware. On PCI all interrupts are level, on ISA they are edge.  As far as I know there is nothing 
you can do about that.

> 
> _______________________________________________
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post22368
>