Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Logic PD support staff and engineers participate, Logic PD does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Logic PD engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Logic PD product download, please subscribe to the TDG Forum of interest.

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 03 Nov 2008 02:23 PM by  scobb
Simple Interrupt Implementation
 10 Replies
Sort:
You are not authorized to post a reply.
Author Messages
ftiernan
New Member
New Member
Posts:


--
31 Aug 2005 11:56 PM
    I 'd like to attach an optical encoder to my project and would like to use the pre-established interrupts INT2 (Port F bit 2) and INT1 (Port F bit 1) on the LH7A400 board. I can set up the physical interrupts on the board and create a thread and an s/w "event" to trigger the thread but am not sure how to link my s/w "event" to the physical interrupt that will be triggered by the encoder when it is turned. I know that the physical interrupt will be generated but how to communicate this to my program is my question. Is there a pre-existing generic ISR that I can link to in some way? I've looked through the other posts here and the CE help but most seem to involve separate drivers and installable ISRs etc. which I hope avoid if possible, just keeping it as simple as possible and all within my .cpp program. Maybe this is wishful thinking but thought i'd ask. TIA - Frank T.
    mikea@logicpd.com
    New Member
    New Member
    Posts:


    --
    01 Sep 2005 05:00 PM
    Is this in Windows CE, another OS, or a non-OS application?

    Thanks,
    -Mike A.
    ftiernan
    New Member
    New Member
    Posts:


    --
    01 Sep 2005 06:24 PM
    Windows CE using Platform Builder 4.2
    mikea@logicpd.com
    New Member
    New Member
    Posts:


    --
    06 Sep 2005 11:12 AM
    Ok,
    This is a very standard thing. The first thing you can check out is our example 'foo' driver, which uses an installable interrupt. If you are going to use IRQA or IRQB from the card engine and it is only used by one device (you are not sharing the interrupt between several devices), you don't need to necessarily use an installable interrupt.

    The foo driver is located here:
    http://www.logicpd.com/do...FOO_tag_50_1_1_0.zip

    Notice, this is for CE 5.0, but just open the source to see what we are doing.

    I will try to post the basics of using an interrupt without creating the installable ISR driver on this post a little later, I have to get the info ready. For now, this is a good place to start thoug
    ftiernan
    New Member
    New Member
    Posts:


    --
    08 Sep 2005 11:27 PM
    Thanks Mike, your link took me to a License agreement which I filled out and faxed in. - Frank T.
    ftiernan
    New Member
    New Member
    Posts:


    --
    18 Sep 2005 11:12 PM
    Hello Mike,

    I added the foo driver to my platform and rebuilt it. To get started all I want to do is trap taking pin f1 low (by grounding it). I set up pin F1 as a as falling edge triggered interupt (IRQB) and have added the following to the InitInstance function of my application:
    Quote:

    DWORD my_sysIntr;
    DWORD dwIntr = 5;

    KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR,(VOID *) &dwIntr, sizeof(dwIntr), (VOID *) &my_sysIntr, sizeof(my_sysIntr),NULL);

    InterruptInitialize(my_sysIntr, g_hIntrEvent, NULL, 0);


    I set up a thread (also in the application) to wait on g_hIntrEvent and then just print something to the screen saying it caught the interrupt.

    After rebooting the whole system this works once (when I ground pin F1 the message pops up) but the interrupt does not seem to clear as I cannot get it to trigger again. I.e. after I clear the screen and remove the ground and then reground the pin no interrupt is detected. Probably I'm missing something basic here so any help you could provide would be appreciated. Thanks Frank T.
    ftiernan
    New Member
    New Member
    Posts:


    --
    24 Sep 2005 03:45 PM
    Hello Mike,

    In going back over this problem I think that perhaps the platform did not rebuild properly after adding the foo driver to the platform according to the instruction in your readme.txt file. Everything seems to go properly in that the foo driver appears in both the Cataloag and Platform windows but when I rebuild the platform I get the following error message:
    Quote:
    Windows CE ROM Image Builder v4.0.000 Copyright (c) Microsoft Corporation
    Built: Mar 14 2003 09:04:08
    Error: Could not find file 'C:\WINCE420\PUBLIC\custom_shell_6\RelDir\LOCE_A~2\lpd_LOCE_foo.dll' on disk
    lpd_LOCE_foo.dll C:\WINCE420\PUBLIC\custom_shell_6\RelDir\LOCE_A~2\lpd_LOCE_foo.dll NK SH
    Error: failed setting line
    makeimg: FATAL ERROR: Command returned non-zero exit code 1 (dec).
    makeimg: FATAL ERROR: Command returned non-zero exit code 1 (dec).
    Error PB2505: Error executing #(C:\WINCE420\PUBLIC\custom_shell_6\RelDir\LOCE_A~2\)makeimg.exe.

    CUSTOM_SHELL_6 - 5 error(s), 0 warning(s)


    Any suggestions? Do I need to manually add anything to the platform.reg file? Thanks - Frank T.
    mikea@logicpd.com
    New Member
    New Member
    Posts:


    --
    26 Sep 2005 09:39 AM
    That driver (foo) is made to run from our 5.0 BSP. It is not set up correctly to run out of the CE 4.2 BSP without some changes. You will likely need to bo build it manually using a command line build. This driver is there as an example, and especially for 4.2, can not be used 'as is'.

    I highly suggest creating your own little driver that you first makes sure it loads correctly and then start putting in some content. Besides the code in the foo driver, here are some other good links:

    http://msdn.microsoft.com...handlingoverview.asp
    http://msdn.microsoft.com...essingcomponents.asp
    http://msdn.microsoft.com...nceinterruptarch.asp

    If you would like Logic's support team to work with you directly on this, please email platformsupport@logicpd.com.
    mikea@logicpd.com
    New Member
    New Member
    Posts:


    --
    26 Sep 2005 09:41 AM
    Also, if you had your IST run once, could it be that you are not calling 'InterruptDone()' in your IST?
    ftiernan
    New Member
    New Member
    Posts:


    --
    09 Oct 2005 11:48 PM
    Hello Mike,

    Thanks for your suggestions. I decided to move over to CE 5.0 and that solved my problems.

    For the sake of completeness I will post a couple of items that I needed to change in order to get up and running.

    In the foo.c program I needed to add the line:

    Quote:
    InitializeCriticalSection(&v_StateCritSect);


    in the FOO_Init function as it seemed that v_StatCritSect was not initialized elsewhere.

    As I wanted to signal a thread in my application I needed to name the event that is pulsed in the driver IST and then create an event with the same name in my application which was used to trigger a thread in my application. Using the name FooEvent, I change the CreateEvent call in the foo.c as follows:
    Quote:
    hFooUserEvent = CreateEvent(NULL, FALSE, FALSE, TEXT( "FooEvent" ));


    With those changes, things appear to be working as intended.

    Thanks again,
    Frank T.
    scobb
    New Member
    New Member
    Posts:


    --
    03 Nov 2008 02:23 PM
    Resurrecting an old issue – but it seems to fit well.

    On an A400, running CE 4.2 we set up an interrupt handler based on the Foo.c example from LogicPD. Everything worked fine for IRQA, IRQB and IRQC.

    The Foo.c example uses a Low Level triggered interrupt. This worked fine for our application.

    However, we have found that we miss one in 10,000 to 40,000 interrupts. On further investigation, I found that the interrupt source is pretty short in duration ~13usec.

    If I increase that duration to 25usec it never has a problem. I first tried 15usec and had an issue so I jumped to 25 – now it is OK.

    So – the questions:
    1) For level triggered interrupts, Is there a spec on how long an interrupt signal must be to guarantee detection?
    2) It seems like a falling edge triggered interrupt would be more appropriate. Is there a reason to avoid them – or caveats that I should know about? Has anyone used them on an A400?

    Thanks,
    Steve
    You are not authorized to post a reply.