Interrupt J5 Pin1

  • Hello


    I try to use (on Netdcu8) connector J5 the Pins 1-4 for input interrupts.
    Pin 2,3,4 are working properly. Pin 1 only works one time after power on of the Netdcu and program start. When closing and restart the program again, Pin 1 is´nt rising a interrupt anymore, only Pin 2,3,4 are working ok. I have to say I use a customer kernel with CF35.
    Could you give me a idea what I could check?



    I like to show here the code fragments for the Pin1:


    I initialise so:

    Code
    1. m_hIsrEvent_J5_Pin1=CreateEvent( NULL, FALSE, FALSE, _T("ISR_Pin1") );//Geht nur als interupt
    2. //DIGITALIO driver is not respsonsible for this pin.
    3. //The interrupt is triggered at low level, not at an edge.
    4. m_dwSysIntr_Pin1=SYSINTR_EXTIO; //J5 pin 1
    5. if(!InterruptInitialize(m_dwSysIntr_Pin1,m_hIsrEvent_J5_Pin1,NULL,0))
    6. {
    7. ErrorMessage(_T("J5 pin 1 InterruptInitialize failed"));
    8. return false;
    9. }
    10. InterruptDone(SYSINTR_EXTIO);


    The waiting part:

    Code
    1. DWORD dwReturn=WaitForSingleObject(m_hIsrEvent_J5_Pin1,INFINITE);
    2. #if(TRIGGER==TRIGGER_LEVEL)
    3. Sleep(100); // TODO
    4. #endif
    5. InterruptDone(SYSINTR_EXTIO);
    6. RETAILMSG(1, (_T("\r\nirq pin1 received")));


    When program stop I do this:

    Code
    1. InterruptDone(SYSINTR_EXTIO);
    2. InterruptDisable(SYSINTR_EXTIO);
    3. DeviceIoControl( m_hDIO, IOCTL_DIO_RELEASE_SYSINTR, &m_dwSysIntr_Pin1, sizeof(DWORD), NULL, 0, NULL, NULL );
    4. SetEvent(m_hIsrEvent_J5_Pin1);


    The registry settings:
    reg set value Channel dword 20
    reg open \drivers\builtin\digitalio
    reg set value port dword 0
    reg set value index dword 0
    reg set value UseAsIO DWORD 0x00ff0fff
    reg set value DataDir DWORD 0x00000f1f
    reg set value DataInit DWORD 0x00000000
    reg set value IRQCfg0 DWORD 0x000000e0
    reg set value IRQCfg1 DWORD 0x000000e0
    reg set value IRQCfg2 DWORD 0x00000000

  • Hello,
    do not call "InterruptDisable".
    When stop your programm call following, this should work:

    Code
    1. ...
    2. if(DeviceIoControl( m_hDIO, IOCTL_DIO_RELEASE_SYSINTR, &m_dwSysIntr, sizeof(DWORD), NULL, 0, NULL, NULL ))
    3. ...
    4. if(m_hIsrEvent_J5Pin1!=INVALID_HANDLE_VALUE)
    5. CloseHandle(m_hIsrEvent_J5Pin1);
    6. ...

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • The problem is, when I not call InterruptDisable(SYSINTR_EXTIO), I never get out of the blocking call WaitForSingleObject(m_hIsrEvent_J5_Pin1,INFINITE)
    ,what is waiting all the time for the interrupt, and can not end my programm properly. Don´t ask me why this is so, the other 3 interrupt inputs (Pin2,3,4) are well working with this.
    Do you have other ideas what I could try?

  • Hello,
    you may use:
    - SetEvent() for run through WaitForSingleObject() while closing the program.
    - Or call WaitForSingleObject() using a time out and evaluate the return value.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello,
    i suggest you call "SetEvent" to late (after disabled and released irq), try

    Code
    1. //When program stop I do this:
    2. SetEvent(m_hIsrEvent_J5_Pin1);
    3. DeviceIoControl( m_hDIO, IOCTL_DIO_RELEASE_SYSINTR, &m_dwSysIntr_Pin1, sizeof(DWORD), NULL, 0, NULL, NULL );

    instead of

    Code
    1. //When program stop I do this:
    2. InterruptDone(SYSINTR_EXTIO);
    3. InterruptDisable(SYSINTR_EXTIO);
    4. DeviceIoControl( m_hDIO, IOCTL_DIO_RELEASE_SYSINTR, &m_dwSysIntr_Pin1, sizeof(DWORD), NULL, 0, NULL, NULL );
    5. SetEvent(m_hIsrEvent_J5_Pin1);


    PS: is DeviceIoControl( m_hDIO, IOCTL_DIO_RELEASE_SYSINTR...) not already sufficient for run through WaitForSingleObject()?

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • I did what you say but still the interrupt only comes after power on and nomore after program restart.
    I work in a DLL, does this matter?
    Also strange, after I do


    Code
    1. DeviceIoControl( m_hDIO, IOCTL_DIO_RELEASE_SYSINTR, &m_dwSysIntr_Pin1, sizeof(DWORD), NULL, 0, NULL, NULL );
    2. this->WaitISR_J5_Pin1();


    and then want to close the IST event handle


    Code
    1. if(m_hIsrEvent_J5_Pin1!=INVALID_HANDLE_VALUE)
    2. {
    3. CloseHandle(m_hIsrEvent_J5_Pin1);
    4. m_hIsrEvent_J5_Pin1 = INVALID_HANDLE_VALUE;
    5. }



    The code sticks in the CloseHandle()....Program cannot finish.
    If I do all the stuff my way (also Pin1 working not correclty) then I can close the handles properly.
    Very strange stuff.


    Any idea?

  • Hello,
    - i dont think wrap functions in DLL causes the problem. Which kind of DLL do you use for load/access irq functionality?
    - i program a simple sample for test and realize, that for the J5.1 no IRQ have to be requested (it is an IRQ "by default"), so no release of IRQ is neccessary! But i dont think that the call of "IOCTL_DIO_RELEASE_SYSINTR" causes the problem - did you checked return value and error code? Nevertheless following works. I use latest kernel (V1.45):

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • This is funny, I just made a test.
    It works when first starting the program.
    Then I start program again, and the program stops because an interrupt was triggered, but not from me.
    Then I start again, and it is working ok.
    So every odd try it is ok.
    I have a user defined Kernel from 15.3.10


    I will try your kernel too.

  • Hello,
    i run my test on your kernel (base is V1.42) and it works in the same way as under V1.45. I also see no relevant changes between V1.42 and 1.45 in history.txt refering IRQ.


    Quote

    So every odd try it is ok ...

    For this fact you have opend already an other thread i think: http://www.forum.fs-net.de/viewtopic.php?f=2&t=2665.

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • Hello


    All very strange...
    With odd I meant that odd number of program start is ok and even number of program start it is not working ok.
    I don´t understand what you mean with the relation of my other thread please get me on it.


    Should we check if our hardware is really the same?