Problem with PCI card interrupt programming

Hi all

I try to program to get data from PCI digital I/O card. For get data with polling, it work well then i try to use interrupt it not work , alway waiting Interrupt. my some code is :

{
struct pci_dev_info info;
struct sigevent event;
void *hdl;
memset(&info,0,sizeof(info));
memset(&event, 0, sizeof(event));
event.sigev_notify = SIGEV_INTR;

 ThreadCtl(_NTO_TCTL_IO, 0);
 
 pci_attach(0);   
 info.VendorId   =  0x144a;
 info.DeviceId   =  0x7348;

  hdl = pci_attach_device(0,PCI_INIT_ALL, 0, &info);          

}
BASE = mmap_device_io(info.BaseAddressSize],info.CpuBaseAddress [2]);
IRQNUM = info.irq;

irqid = InterruptAttachEvent(IRQNUM, &event, 0 );

while(1){

                        InterruptWait( NULL,NULL );                            
                        printf( " Interrup occur  %d\n" ,count);
                        terruptUnmask( IRQNUM, irqid );   		       
                                                       
             }
                        InterruptDetach( irqid );

}

What are my probelms ? and how to slove it

Since you didn’t include any error checking (in your example), does the pci_attach_device() work? Are the CpuBaseAddress[2] and size field equal to what you see with the pci utility? How about the irq?

A trick I use to test code sometimes is to attach to the irq for the mouse - then I can just use the mouse to generate interrupt and test part of my code. :slight_smile:

Rick…

For attach PCI it no problem. I can get data vai PCI I/O card and for interrupt program, it was tested with ISA card it work well. I did not know the problem. It should set a priority for it. Isn’t it ?

watcharin

I think I lost something in the translation.

Does the results you get (BASE, IRQNUM), match what the ‘pci’ utility shows for the board? You may have to use ‘pci -v’ to see the board’s data.

Rick…