ISR on Windows CE 6 RRS feed

  • Question

  • Hello,

    I'm developping an application which use a PCI Card. For the commincation with the card, I have kernel drivers.

    I use an ISR to receive data or to send data, all the data are bufferized.

    The application works fine during ~5 minutes, but then I have an access violation immediately after enterring in my


    I'm just sure about something : my buffers don't cause this exception. I tried to send data which are not bufferized and the

    access violation comes after ~5 minutes too.

    The main application was developped for windows ce 5, we ported it to ce 6 but it is still problematic.

    The mechanism for ISR and IST is the same as in the documentation, with the loadIntChainHandler, ... and the IST is a thread which waits with "WaitForSingleObject", ...

    With those information, can I be sure that the problem is related to the ISR ? In fact, I think that when the ISR is executed nothing else is running (I don't have other interrupts with higher priority).So maybe my configuration is false or the memory shared between the IST and the ISR is not well protected.

    Or maybe my application writes something in the memory space allocated to the ISRHandler and the process context is afftected. So, is it possible that during the ISRHandler an other process makes an exception ?

    I have one more question which is more theorical, does the ISRHandler have a specific thread-id ? or does it take the id of the last thread which was running ?

    Thank you in advance !

    Wednesday, April 4, 2012 12:32 PM

All replies

  • So, I always have this problem but I modified it to do more tests.

    So now, I have a software which only sends CAN frames. When it sends a frame, the "Can controller" sends the message on the CAN line and then raises an interrupt. When I receive the interrupt, my "ISRhandler" checks if I have another frame to send. For my tests, I always have a message so the program always enters in my isr and then sends a frame then enters in my isr and send sa frame and so on. After sending more than 300'000 frames, The program crashes with more than 140 access violation. I don't do dynamic allocation, so I don't think that I'm writing somewhere where I don't have the right to.

    So I think that I probably have a stack overflow, in other case I would have only one "access violation". Is there a way to check if I have a stack overflow ? Does somebody think that I have another problem ? I am a beginner in this world (Windows CE, Isrs, ...) so do you have any tips ? Or important things to check ?

    Thank you !

    PS : English is not my native, so sorry if my messages contain mistakes ;-)

    Tuesday, April 17, 2012 12:18 PM
  • When your ISR is running, you are correct nothing else is running becuase it is in an ISR.

    I am not sure why you are sending CAN messages in the ISR rather than in the IST.   By doing so, you must be staying in the ISR for longer than is probably good.

    As to why you are getting an access violation, the best we can say is that it is becuase you are accessing an address that your codes doesn't have permission to access.   But there must be more information output on the debug port than just Access Violation, share that with us.

    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.

    Tuesday, April 17, 2012 9:40 PM
  • Hello,

    Thank you for your reply !

    Here is the output of the access violation :

    Exception Access Violation (14): Thread-Id=03660002(pth=8ce10d20), Proc-Id=02b20002(pprc=8cc2d000) 'servicesd.exe', VM-active=02b20002(pprc=8cc2d000) 'servicesd.exe'
    EIP=8404a7f1 Flags=00013246 EA=d012fcc4
    Eax=0012ff00 Ebx=8404a9be Ecx=844ed254 Edx=844ed000
    Esi=844ed254 Edi=844ed1c4 Ebp=844ed164 Esp=844ed15c
    CS=0008 DS=0040 ES=0040 SS=0010 FS=0060 GS=0000

    I always have 143 acces violation like this one. The name of the process is not always the same, sometimes it is "MyApplication.exe", sometimes "NK.exe", sometimes "servicesd.exe", ...

    For the moment, my ISR is very very light. It only have 3-4 lines to write on the "CAN" line.

    I don't think that I'm writing somewhere where I don't have the right to. I had this type of exception and it was only one access violation exception. Now I have more than 140. My application is very very light it only sends a hardcoded message so I don't do dynamic allocation of memory.

    Sending message form the IST can be a good solution I will try to do it.

    Wednesday, April 18, 2012 7:33 AM
  • So, I have new information : (I'm always sending from the ISR)

    - My ISR calls 3 fonctions (defined in the same file) : If I copy+paste their code in the ISR instead of calling them, the programs runs longer (it is running now, and it has sent more than 4'000'000 frames and it is still running).

    So I probably have a problem with the stack.

    Is it legal to call 3 functions (with parameters) in my ISR ? Is there a way to protect the stack when I'm in the ISR ?

    Thank you in advance !

    Wednesday, April 18, 2012 8:05 AM
  • Why are you doing this from an ISR instead of the IST?

    Since we don't know anything about what you have specifically done it would be premature to comment on caling those functions.

    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.

    Wednesday, April 18, 2012 12:42 PM
  • So I changed my application, and I send my frames from the IST. My ISR only checks if I have something to send. But in my ISR, I also read the frames sent by the devices, I cannot read from the IST because it's to dangerous and it is possible to lose frames.

    I always have the same problem but I can send and receive more frames.

    Now, I have one question : Is it true that the register esp must be smaller than the register ebp ? It must be true, from what I understood the Windows stack goes down so the the base of the stack is higher than its top.

    I ask that because my 140 exception are not always the same and some of the exceptions show that ESP is higher than EBP. I think I do something wrong and it corrupts the stack. 

    Is it possible to add some assembler instructions to protect the current context when I enter in my ISR ?

    Thank you in advance !

    Friday, April 20, 2012 6:59 AM
  • If you are corrupting the stack, then you really need to review you code carefully.  You must be doing something quite wrong.

    Dangerous to read frames from an IST - why?   We have been doing that for years without problem or lost frames.

    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.

    Friday, April 20, 2012 12:44 PM