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
The problem is that you are calling the same function from both interrupt and non-interrupt code:
http://www.keil.com/support/man/docs/lx51/lx51_l15.htm
It is also usually very bad practice to do stuff like printing from within an interrupt. In general, Interrupt Service Routines (ISRs) should do the minimum necessary to capture any data, and inform the main loop of the event; the main loop then does any long-winded processing like printing.
Hi Andy, I only want to take input for my key press but i want to also redirect to another function without going back to main which is not possible from what i have read till now so i wanted to do the display there. i am running a critical process which should quit only on interrupt. In my main loop i don't want to check for any value. I can always put the value of the key press in a memory location and read it but that is what i want to avoid. Reading any thing will put my critical process out of loop. Do you think it is possible for me to go to another function without going to main. ie quiting the main only on an interrupt and doing the rest of function outside.
Ex. Let us say This is my main
void main() { while (1) { } }
and
void int0 (void) interrupt0 { } myproc() { }
can i run my proc directly on interrupt but myproc is quite long and will have displaying and various other functions that are in other function which are not in main but called from it. main is very small.
i am running a critical process which should quit only on interrupt.<p>
In that case, the process cannot be really "critical" (since it can be interrupted). You may want to specify the processing needs of this process more clearly, as in when and how long it may not be running.
The usual way it to set some flag in the interrupt service routine, and have main (or some other function that runs periodically) check this flag to see if the actual processing/output routine needs to be called.
Hi Christoph,
I say it is critical because i am checking for wegand data such that it is comming at any interval and needs to be processed as soon as it arrives if i miss a few bits the whole data is of no use and i do not have a buffer for it either. When an interrupt comes from key pad the data is assumed to be stoped and even if it arrives should be ignored that is the reason i said it is Critical. i am using interrupt to avoid missing any data.
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]); }
Just figure: how long does this interrupt take to process.
Erik
View all questions in Keil forum