/*
Here I done one timer example which fires for every 1 sec and it will send event.
*/
[code]#include <stdio.h>
#include <time.h>
#include <sys/netmgr.h>
#include <sys/neutrino.h>
#include <sys/syspage.h>
timer_t timer_id;
time_t timer;
struct sigevent event;
const struct sigevent * isr_handler(void * area,int id);
static volatile int g_iTemp;
/ISR Handler function/
const struct sigevent * isr_handler(void * area,int id)
{
printf(“In isr function****\n”);
InterruptMask(0,id);
g_iTemp = SYSPAGE_ENTRY(qtime);
//event.sigev_value.sival_int = 20;
return &event;
}
void Isr_Thread()
{
printf(“In Isr thread\n”);
event.sigev_notify = SIGEV_INTR;
printf("Isr Thread Id:%d\n",pthread_self());
//const struct sigevent * (*ISR_handler) (void *,int ) = &isr_handler;
if(InterruptAttach(0, isr_handler, NULL, 0, 0) == -1)
{
printf("\n\t\t InterruptAttach/Event Function failed \n");
return -1;
}
timer_create(CLOCK_REALTIME, &event, &timer_id);
struct itimerspec itime;
printf("Timer Thread Id:%d\n",pthread_self());
itime.it_value.tv_sec = 1;
itime.it_value.tv_nsec = 0;
itime.it_interval.tv_sec = 1;
itime.it_interval.tv_nsec = 0;
timer_settime(timer_id, 0, &itime, NULL);
while(1)
{
printf("ISR is waiting\n");
printf("Before Interrupt Wait event.sigev_value:%d\n",event.sigev_value.sival_int);
InterruptWait (NULL, NULL);
timer = time(NULL);
printf("After Interrupt time is:%s\n",ctime(&timer));
printf("Interrupt Came,so InterruptWait unblocked\n");
printf("Value of g_iTemp:%d\n",g_iTemp);
}
}
main()
{
struct itimerspec itime;
int id;
printf(“Main Thread Id:%d\n”,pthread_self());
/* Obtain I/O privileges */
ThreadCtl( _NTO_TCTL_IO, 0 );
timer = time(NULL);
printf("Before calling thread time is:%s\n",ctime(&timer));
/* Start the thread that will handle interrupt events. */
pthread_create (NULL, NULL, Isr_Thread, NULL);
char ch = 0;
printf(“Press enter to exit\n”);
scanf("%c",ch);
}[/code]
Question1:
After every 1 sec, timer is firing,“InterruptWait” is unblocking,But “isr_handler” is not called.
Because after Interrupt came, I checked the value of g_iTemp,but it’s value is 0 only why?
Question2:
If I comment “InterruptAttach” function also, Interrupt is generating.So It mean that for every
1 sec timer will fire irrespective of interrupt registration through “InterruptAttach” function.i.e timer will
fire for every 1 sec and it will notify through signal like SIGEV_INTR,SIGEV_PULSE(whoever waiting).
Am I correct?.If i am correct, in my case(Refer earlier post) FPGA is generating interrupt. But ISR function
is not calling.How can I solve this issue?