This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Interrupt Handling Problem

Hi,
I am trying to use Interrupt to check if a key has been pressed on the key pad for this i just wrote a sample code to test it out but i am having the following difficulty

*** WARNING L15: MULTIPLE CALL TO SEGMENT
SEGMENT: ?PR?_IPRINT?BKMAIN
CALLER1: ?PR?INTER0?BKMAIN
CALLER2: ?C_C51STARTUP
***ERROR L107: ADDRESS SPACE OVERFLOW
SPACE: DATA
SEGMENT: _DATA_GROUP_
LENGTH: 001BH
Program Size: data=181.6 xdata=0 code=17362
Target not created

Now i am using many functions where i am calling the same function but it is not giving me an error there what can i do to avoid this error

The error comes when i include the following code

void Inter0 (void) interrupt 0
{
clear();
init1();init1();
iprint("Inside Interrupt");
}

iprint is a display function which is

void iprint(char *aaa){
unsigned int i=0;
for(;aaa[i]!=0;i++)display(aaa[i]);
}

if i write the code like this

void Inter0 (void) interrupt 0
{
clear();
init1();init1();
display('a');
}

It dose not give me any error. and the code compiles properly

Parents
  • Hi,

    I would suggest that you look into structuring your code so that the ISR accumulates the Wiegand data into a buffer as it arrives and sets a flag to indicate accumulation complete.

    Then, the main foreground loop can poll the 'accumulation complete' flag and process all of the data when available.

    It would be critical to accumulate the bits with no chance of missing any - Processing the data is not (normally) so critical.

    I have used this technique on a number of media acquisition modules (Wiegand, magstripe and barcode) for a number of years and found it to be a good reliable method.

    The key point is that you should try to keep the ISR as small (and efficient) as practically possible - Get in and out quickly.

Reply
  • Hi,

    I would suggest that you look into structuring your code so that the ISR accumulates the Wiegand data into a buffer as it arrives and sets a flag to indicate accumulation complete.

    Then, the main foreground loop can poll the 'accumulation complete' flag and process all of the data when available.

    It would be critical to accumulate the bits with no chance of missing any - Processing the data is not (normally) so critical.

    I have used this technique on a number of media acquisition modules (Wiegand, magstripe and barcode) for a number of years and found it to be a good reliable method.

    The key point is that you should try to keep the ISR as small (and efficient) as practically possible - Get in and out quickly.

Children
  • I would suggest that you look into structuring your code so that the ISR accumulates the Wiegand data into a buffer as it arrives and sets a flag to indicate accumulation complete.

    The baove, while correct, is too limited. This, by no means, is a 'wiegand' or such issue.

    more complete : if at all possible, no processing of incoming data should take place in the ISR

    Erik

  • more complete : if at all possible, no processing of incoming data should take place in the ISR

    Erik,

    I totally agree with your comment - It is a maxim which I have followed for years.

    Since the thread originator mentioned wegand (meaning Wiegand ?), I thought that it might be useful (to him) to describe the task in that manner.

    Whichever - I hope he finds my/your/our comments useful.

    David.

  • Hi David,

    Sorry for the late reply but i'm from india and for me your input came in the night.
    I am not so good with interrupts as you might have seen from my code.
    How do I use the ISR to collect data ? should i give the data pin to an interrupt?.

    Thanks.
    Ajay

  • Hi,

    Assuming you are talking about collecting Wiegand data:

    If you have the CPU resources available, one way would be to connect D0 to INT0 (P3.2) and D1 to INT1 (P3.3). Depending upon your hardware, you may need to invert the signals.

    Configure both inputs as edge interrupts.

    When an interrupt occurs:

    1 - Add a ZERO or a ONE to an accumulation buffer (depending upon which interrupt occured)
    2 - Increment a 'bit received' count
    3 - If all data has been received, disable the interrupt(s) and set a flag to say 'acquisition complete'

    This is a similar technique to one I have used on a number of platforms with a number of CPU cores - Although I have various other checks to ensure that it is completely resilient to all predicted possible situations. For example, you may want to include a timeout check to ensure that the acquisition does not wait forever if a bit is unexpectedly missed.

    Hope this helps,

    David.

  • Hi David,

    Thats will work, i think, i will try it out and yes i mean Wiegand data, sorry about the spelling mistake i'm weak at English.
    Thank You very much.
    Ajay

  • "Wiegand" sounds more like German to me!

    ;-)

  • You never know it might have been a German who thought of it and named it after his son :))))