Page 1 of 1

Serious Warning: Possible sw stack corruption, function

Posted: Sun Feb 28, 2010 8:57 am
by medelec35
After compiling I have got the following warnings:

Code: Select all

Serious Warning: Possible sw stack corruption, function '__mul_8u_8u' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function '__mul_16s_16u__16' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Although Hardware is running great, I would like to eliminate cause of warming's. I have kept interrupts to a minimum with no delays within etc.
May be a start would be finding out what __mul_8u_8u' & __mul_16s_16u__16 are. I have turned on sw stack and allowing an extra 2 in depth.
Due to the nature of hardware i.e running two EC motors, with taco feed back to keep speeds precise,after reading pot then determine required rpm from look-up table.
I thought two interrupts are conflicting, but after deleting port B interrupt, still same errors. Is is possible to solve this without posting sw, and going by the above warnings please?

Re: Serious Warning: Possible sw stack corruption, function

Posted: Sun Feb 28, 2010 4:02 pm
by Eric
Hello Medelec,

I had a similar problem lately: see http://www.matrixmultimedia.com/mmforum ... 968#p16515
It turned out to be a delay problem: 2 macro's using the same delay routine simultaniously.
The solution from Steve ( replacing the delay by a loop ) solved the issue.
Maybe this helps.

Regards,

Eric

Re: Serious Warning: Possible sw stack corruption, function

Posted: Sun Feb 28, 2010 5:41 pm
by medelec35
Hiya Eric.
Yes I remember replying to that thread, as it happens just a lucky guess :)
The difference between your error message and my error message is yours use the word 'delay_us'
My error uses the words '__mul_8u_8u' & '__mul_16s_16u__16' and not sure what mul is?
My guess it has something to multiplication of 8 bit and 16 bit integers?
But I can't see how two can conflict since two routines re called separately.......Ah unless there is a risk of while one calculation is being executed, there is a risk of a interrupt taking place and overwriting the same routines which would overwrite original variables because a common temporary storage area for variables is used, since I do have some formula duplications. Still I 'm going to try your method of elimination in attempt to locate the problem area.
Your post has helped, thanks Eric.

Re: Serious Warning: Possible sw stack corruption, function

Posted: Sun Feb 28, 2010 6:17 pm
by medelec35
Yay solved it. 8) It appears its just not just delays, or macro routines like LCD commands that can't go in interrupt macros, it is also formula involving 8 or 16bits since calculations probably use same registers. Ben, Steve or Sean, is that correct? Since removing formula eliminated warning. All I did was place a variable set for 1, in place of the formula within interrupt routine. Then in main, created a decision if variable =1 then carry out formula and set variable to 0. But since interrupt could occur quicker then the formula being executed, the counter in the interrupt is inhibited until variable is set to 0. Sorted.

Re: Serious Warning: Possible sw stack corruption, function

Posted: Mon Mar 01, 2010 10:26 am
by Benj
Hello

Yes it sounds like there is a multiplication routine that is called and may cause corruption if you are inside the function and an interrupt occurrs. It would be good to see what kind of calculation requires these multiplication functions. There may be a way to force Flowcode to compile a bit less efficiently but that gets around this potential problem. Please can you send me a Flowcode file that exibits this behavious and I will look into it.

Re: Serious Warning: Possible sw stack corruption, function

Posted: Mon Mar 01, 2010 1:09 pm
by medelec35
Sure. Both files sent.
Thanks Ben.