We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am seeing this warning when I try to compile my code
Warning L15: multiple call to segment segment: ?pr?_nvmwrit?nvmem_cc caller1: ?pr?spicommisr?spi_com_cc caller2: ?c_c51startup
I looked through my code, I don't call nvmwrite in spicommisr routine. And what is this c51startup file?
thanks, DG
... takes a lot of care and is error prone, just don't do it. I once saw a case of somebody fighting a bug for a long time, it turned out that a subtle change had made a carefully crafted, following all the rules routine shared by main and an ISR not be shareable any more.
Erik
I did have that nvmwrite in isr before, but I already moved it out. Right now, I only set flag and take care of that nvmwrite in supper loop which belongs to main. I don't understand why linker still thinks I have that nvmwrite in isr.
And what is that C51startup anyway?
C51startup is the code that runs before main is called then calls main(). If your project does not have one the compiler will use the default.
if the linker is confused try to rebuild all or delete the object files then try to build again.
Mayby it will help if you change the Code Optimation Level, try it.
When I reduce optimization level to level 1 (dead code elimination), the warning goes away. If I increase to level 2 (data overlaying), the warning comes back.
and solution or I stuck with level 1 optimization?
Is it safe to ignore the warning? Is changing nwmwrite to reentrant a safe option?
thanks,
I stuck with level 1 optimization? no
Is it safe to ignore the warning? no
Is changing nwmwrite to reentrant a safe option? yes, but that is NOT fixing the problem, just hiding it
do a global search on nwmwrite and get rid of the offending call.
if you need it both in main and an ISR, make 2 (differently named) copies.
if the function is called from anything with using 1, 2 or 3 it must have 'using' the same in its header
Maybe the following manual information will help.
http://www.keil.com/support/man/docs/c51/c51_xf_recursivecode.htm
Jon
this happens when a functions is called in isr as well as in general routines so to avoid it add reentrant in the declaration as well as in definition of the function eg: if foll function is called: void function(void) then rewrite it as void function(void) reentrant in declaration as well as in definition
you will also - in many cases - have to add NOAREG.
This calling a function from both ISR and main is something, that the implementation that Keil fortunately have chosen in order to to work the best with the 'features' that the '51 architecture has, get to be almost an "implementation violation".
Yes, you buggers that insist that "C is C who gives a hoot that it is on a '51" will, of course consider it an "unnecessarily cumbersome implementation of standard C". if you insist that "C is C" I suggest you get yourself a PC to program.
if you insist that "C is C" I suggest you get yourself a PC to program.
Too a harsh a judgment I think. A couple of years ago I was involved in the development of, what I still consider, the most beautiful piece of time critical C (and some C++) code I ever saw, which was written mostly in standard C/C++. Things were not taken to extremes to squeeze the processors (XC167CI), but that did not reduce the code's functional value and did not change the fact the it bread an entire generation of successful machines. I doubt whether the people that were/still are involved in that effort would appreciate your job offer :-)
Where did that clueless little rant spring from? You've been quite quiet for a while.
But please, if you really insist on making a public fool of yourself, at least try and moderate your language.
Things were not taken to extremes to squeeze the processors no such intent in my post, if you do not need to, then why try? However, there are some things where considering the achitectural facts and the compiler circumvention thereof get important. Basically what I comment on is the udder (yes it i bovine) refusal of some to adapt to what they are working with, namely Keil C51, not just "some C"
guys, I am not sure if you really read through all the message before giving any suggestions. My second post, which is the 3rd from top, clearly says I already moved the function call out of ISR. Right now, ISR only sets flag, and supper loop in main takes care of function call.
I have double, triple, quadruple checked the ISR and global searched nvmwrite function call. However, I do not understand why linker still complain that I have nvmwrite call from ISR when I have optimization level > 2.
Maybe the compiler performs common-subexpression optmization, but not on sub-expressions but instead analyses functions with common code and then join the two code chains?
I don't work with the Keil C51 compiler, but quite funny things can happen when a compiler starts doing global optimization.
But a question asked earlier in this thread: Have you made sure that you have erased every single object file, so that the linker doesn't link in one object file from before the change?
I did rebuild all target files and I also tried delete all object files in my hard drive, then compile again. It does not seems to make any difference.
For the time being, I made the nvmwrite to be reentrant so I can keep working on my code. Now I am having a new "multiple call to segment" warning on a different function, but two callers are the same, ISR and C51startup.
Only when I change optimization level to 1, I wouldn't have that warning, but my code is, of course, much bigger.
I can post my code here, but it is kind long...