Cédric Schaffter
11/01/2008 6:10 AM
post15822
|
Hi there :)
I wrote a test application to work with the parallel port. The following code works, but after around 20k interrupts,
the programm freezes.
I place an external source with these parameter :
- period = 100us
- pulse duration = 20us
I also increase these parameters, but the problem persists.
Can someone help me?
//******************************************************************************
#include <stdio.h>
#include <sys/neutrino.h>
#include <hw/inout.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/mman.h>
#define IRQ7 0x07
#define BASE_ADDRESS_LPT1 0x378
#define INTR_BIT 0x10
#define INIT_BIT 0x04
#define MASK_OVLD 0x01
#define MASK_RUN 0x20
#define MASK_ACK 0x10
struct sigevent event;
volatile int id1;
const struct sigevent *handler(void *area, int id);
int main(void){
//variables
int i;
unsigned char reg;
unsigned long lpt;
ThreadCtl(_NTO_TCTL_IO, 0);
event.sigev_notify = SIGEV_INTR;
id1 = InterruptAttach(IRQ7, &handler, NULL, 0, 0 );
lpt = mmap_device_io(3, BASE_ADDRESS_LPT1);
reg = in8(lpt + 2);
out8(lpt + 2, reg|INTR_BIT|INIT_BIT);
while (in8(lpt + 1) & MASK_RUN){
InterruptWait(0, NULL);
i += 1;
i %= 10000;
printf("int %d.\n", i);
}
printf("end of test\n");
munmap_device_io(lpt, 3);
InterruptDetach(id1);
return 0;
}
const struct sigevent *handler(void *area, int id) {
if (id == id1)
return &event;
else
return NULL;
}
//**********************************************************
|
|
|