Stack corruption warning when compiling

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Stack corruption warning when compiling

Post by Zane »

Hi,

I have created a program that is attached below and when it compiles the following message appears.....

Serious Warning: Possible sw stack corruption, function 'float32_addsub' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

When the program runs and the floating point calculations are processed in the main loop the wheels fall off. The only way to get rid of the warning is to disable the call to the interrupt routine (that is needed for speed calculations). I can clear the interrupt routine right out only having a calculator block with 2 lines of code having 2 variables adding one to themselves but the error still persists. I have written a similar program http://www.matrixtsl.com/mmforums/viewt ... 26&t=12650 with floating point calculations and an interrupt routine that has a lot more in it and it compiles fine. I am unable to see the what is happening differently, why one works and the other wont.

Does anyone have any suggestions how to get around this.

Any help would be most appreciated, thanks
Attachments
Odometer.fcfx
(101.92 KiB) Downloaded 256 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Stack corruption warning when compiling

Post by Benj »

Hello,

Currently for 8-bit PIC the Floating point math is done via an external library to the compiler so each floating point calculation has to be done using a function. As we are using a function there are problems if the same function is used inside the main program loop and in the interrupt routine. At some point there is bound to be a point where the main loop is inside the function when the interrupt kicks in and calls the function again. What happens next will be unpredictable.

The floating point function in your interrupt is referring to the WheelTimingCount variable.

Is there a way you can move the calculations involving this variable outside of the interrupt, or simply replace the float variable with a unsigned int variable. If you can do that then it should get rid of the warning and hopefully work as you are expecting.

Zane
Flowcode v5 User
Posts: 199
Joined: Thu Sep 10, 2009 10:57 pm
Location: New Zealand
Has thanked: 93 times
Been thanked: 76 times
Contact:

Re: Stack corruption warning when compiling

Post by Zane »

Hi Ben,

I can see what is going on now :D, thanks for your help.

Post Reply