Hi, The compile error is: WARNING L15: MULTIPLE CALL TO SEGMENT SEGMENT: ?PR?_STRTONUM?PARSE CALLER1: ?PR?TC0?PERIPHERAL CALLER2: ?C_C51STARTUP The callers TC0 is an ISR using reg bank 2 and I don't know about the c51startup. The called function STRTONUM is using the directive of #pragma NOAREGS so can be called for any functions. The question is why I still got the multiple call error? Thanks for answering my question. By the way, C51 is V6.21, BL51 is V4.21 and LIB51 is V4.20. chao.
Function main() also calls STRTONUM function. As the result I have two different functions using different reg banks to call STRTONUM. But still, why would I get multiple call warning since the directive of NOAREGS is used on STRTONUM? Can this warning be ignored? You are calling a function from main AND an interrrupt. 1) this is bad practice 2) if you insist on using this bad practice, you must also make the code reentranr. Erik
erik, First, thank you for your help and thanks to Andy too. I agress with your points. Since it is a bad practice, is there any way to get around other than using reentrant? chao.
is there any way to get around other than using reentrant? Yep. I do this all the time. Here are the main points to consider.
Jon, Thanks, got your help. As I understand you gave me two ways to workaround, disable the interrupt and disable overlay. Here is my project structure: 1. Data is received from uart (interrupt is used). 2. Main() is to analyze the received data and display the result on a screen (LCM). The analyzed data will be shown in different pages, selected by a user. 3. Another ISR (timer 0 to detect a keypad) is also to display the analyzed data on the screen for quickly responding to a user's input. In short, both main and the ISR functions are doing the same thing. The only difference is that ISR can quickly response to a user, simple as that. So my program would not work if I disable the interrupt. On the other hand, if I disable overlay it would take lots of xdata space due to the display subroutines. Do you have any suggestion? chao.
Presumably, this STRTONUM function is just doing some sort of formatting for the display? Why not just keep the formatted result in a buffer, so that both main and the interrupt can access the buffer when they need to display it? This also has the advantage of relieving the ISR of the task of doing the formatting - which is generally a Good Thing.
Writing to an LCD is a very slow (relatively) operation, and not the sort of thing you should be doing inside an interrupt service. Your ISR would be better off setting a flag to note that the LCD requires updating, and regularly check this flag in your non-interrupt code.
Could you not just set a flag in the ISR indicating that main() should call the function? This is the usual sort of technique to avoid these kind of problems. Stefan
View all questions in Keil forum