Hi QNX Community!
I’m writing a software in which I need to synchronize my tasks on an external timer.
In my solution, I configure the 10th pin of the lpt port as interrupt source.
[code]
//*************************************************************
#include <stdio.h>
#include <sys/neutrino.h>
#include <hw/inout.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/mman.h>
#include <unistd.h>
#define IRQ7 0x07
#define BASE_ADDRESS_LPT1 0x378
#define INTR_BIT 0x10
#define MASK_RUN 0x20
int main(void){
//variables
int i, id;
int irqActive;
unsigned char reg;
unsigned long lpt;
struct sigevent event;
ThreadCtl(_NTO_TCTL_IO, 0);
event.sigev_notify = SIGEV_INTR;
id = InterruptAttachEvent(IRQ7, &event,
NTO_INTR_FLAGS_TRK_MSK);
/mapping 3 bytes to configure, read and write LPT port/
lpt = mmap_device_io(3, BASE_ADDRESS_LPT1);
/interrupt hardware set/
reg = in8(lpt + 2);
out8(lpt + 2, reg|INTR_BIT);
printf(“init…\n”);
/waiting start/
while(~in8(lpt + 1) & MASK_RUN);
printf(“start…\n”);
i = 0;
while(in8(lpt + 1) & MASK_RUN){
interruptWait(0, NULL);
i += 1;
i %= 10000;
InterruptUnmask(IRQ7, id);
}
printf("%d interruption(s)\n", i);
munmap_device_io(lpt, 3);
InterruptDetach(id1);
return 0;
}
//************************************************************[/code]
Explainations :
the interrupts signal period is 100us (50% low… 50% high).
I use one input pin to define a start-stop, when this signal is high, I perform my tests.
The problem is :
I can run the test during around 5 seconds, but if I try to test longer… My program “freezes” on InterruptWait.
Does someone have a clue or a answer?
Is it a kind of overflow or is it because the loop is really tight?
I am a little lost because I tried with the internal timer (irq0) and I didn’t get these problems.
I read some websites about IRQ7, but didn’t get information about its servicing.
Thanks for your help and answers.
Hargan