Hi,
I am new to QNX programming and would appreciate your help with a
problem I have in my ISR execution.
I am trying to write an ISR which can service a RTC interrupt on IRQ8.
Most of my code has been extracted from the clock program available at
ftp://ftp.qnx.org.ru/pub/projects/ed1k/clock.tgz
The code extract from this link uses InterruptAttachEvent() and runs
successfully. However, when I try to use InterruptAttach(), the code
does not terminate. I cannot identify the mistake I am making in the
ISR which leads to this condition.
The code is attached below. Thanks for your help!
Ninad
#include <sys/neutrino.h>
#include <sys/siginfo.h>
#include <hw/inout.h>
#include <stdio.h>
#include <stdlib.h>
#include “ISR_test_Ninad_clock_IntAttach.h”
// header file functions have been used successfully in IAE()
scenario
#define IRQ8 8
int interruptID;
const struct sigevent *IRQ8handler(void *area, int id)
{
//Read status C register and clear interrupt request as well
out8(RTC_ADDR_REG, RTC_STATUS_C); // clear interrupt
line
//Unmask our interrupt (it masked by system for us)
InterruptUnmask(RTC_INTR, interruptID);
InterruptNum++;
return (NULL);
}
// MAIN
// ----
int main(void) {
struct sigevent event;
//Check for root privilegies and notificate the kernal
if( ThreadCtl(_NTO_TCTL_IO, 0) == -1 ) {
printf(“Process doesn’t have superuser
capabilities.\n”);
return EXIT_FAILURE;
}
//Check out the RTC status
if( GetRTCStatus() != 0 ) {
printf("Sorry, there is one or few reasons to
exit:\n\
- there is no RTC in your hardware,\n\
- RTC isn’t reachable in standard x86 way,\n\
- your hardware is quite old and battery is
dead.\n");
return EXIT_FAILURE;
}
//Periodic timer prepare
SetRTCPeriod(Hz128); // selects 7.8125 mS period
//Attach interrupt event
SIGEV_INTR_INIT(&event);
interruptID= InterruptAttach(IRQ8, IRQ8handler, &event,
sizeof(event), _NTO_INTR_FLAGS_END);
//Clear pending interrupts
ClearRTCIntrLine();
//Enable interrupts from RTC
EnableRTCPeriodInt();
//Wait for interrupt event
while(InterruptNum<50)
{
InterruptWait(0,NULL);
InterruptNum++;
}
//Disable RTC interrupts
DisableRTCPeriodInt(); // from header file, working
function
fprintf(stdout,"\n Interrupt Routine Successful
\n");
//End of main
return EXIT_SUCCESS;
}