Stack Overflow

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Stack Overflow

Post by Jan Lichtenbelt »

I had a stack overflow of 1 byte:
RAM available:256 bytes, used:179 bytes (70.0%), free:77 bytes (30.0%),
Heap size:76 bytes, Heap max single alloc:75 bytes
ROM available:4096 words, used:3635 words (88.8%), free:461 words (11.2%)


Then I extended the compiler options from
-v -t PIC%p "%f.c"
into
-v -t PIC%p "%f.c" -swcs 6 2

But now I get the error :
Test_PWM.c success
6
Starting preprocessor: C:\PROGRA~2\Flowcode\v5\Tools\boostc\pp.exe 6 -i C:\PROGRA~2\Flowcode\v5\Tools\boostc\include -d _PIC12F1840 -la -c2 -o 6.pp -v -d _BOOSTC -d _PIC16 -d _PIC16x -d _CHAR_INDEX

FATAL: Unable to open input file: 6



What to do?

Kind regards

Jan Lichtenbelt

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: Stack Overflow

Post by Spanish_dude »

Have you tried writing "-swcs 6 2" before the "-t PIC%p ..." ?
Don't think this will do something, but you never know.

Nicolas

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Stack Overflow

Post by Jan Lichtenbelt »

I put the -swsc 6 2 as first argument for the boost compiler options with results:


......
De compiler wordt gestart...(the compiler will be started)
C:\Program Files (x86)\Flowcode\v5\Tools\boostc\boostc_pic16_flowcode.exe -swcs 6 2 -v -t PIC12F1840 "Test_PWM.c"
BoostC Optimizing C Compiler Version 7.04 (for PIC16 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2011 Pavel Baranov
Copyright(C) 2004-2011 David Hobday

Licensed to FlowCode User under Single user Pro License for 1 node(s)
Limitations: PIC12,PIC16 max code size:Unlimited, max RAM banks:Unlimited

warning: unrecognized command line agrument '-swcs', skipped
....


Remarks:
1) The compiler choosen was: boostc_pic18_flowcode.exe. Compiler used is boostc_pic16_flowcode.exe while the PIC12F1840 is used
2) I did read the boostc.pdf which shows still the option used for swsc.

What is going wrong?

Jan Lichtenbelt

PS. Can someone test with in his own flowcode file (does not hurt!)

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times
Contact:

Re: Stack Overflow

Post by wayne millard »

Hi Jan

It seems to work for me if you put it in the linker parameters as follows.

-ld "C:\Program Files\Flowcode\v5\Tools\BoostC\lib" libc.pic16.lib rand.pic16.lib float.pic16.lib -swcs 6 2 "%f.obj" -t PIC%p -d "%d" -p "%f"

Hope This helps

Wayne :D

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Stack Overflow

Post by Jan Lichtenbelt »

Hi Wayne

Thanks a lot. This does not give an error message.

But I still have problems with my program. I believe (not sure) that is due to stack overflow.
Do you think the linker is the right place to change the stack parameters instead at the compiler? If you read the boostc.pdf it should be possible to change the parameter swcs.


Kind regards

Jan Lichtenbelt

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Stack Overflow

Post by Jan Lichtenbelt »

Hi Wayne,

You wright. Swcs is the parameter of boostlink_pic.exe.


But I get still the message:
Memory Usage Report
===================
RAM available:256 bytes, used:179 bytes (70.0%), free:77 bytes (30.0%),
Heap size:76 bytes, Heap max single alloc:75 bytes
ROM available:4096 words, used:3636 words (88.8%), free:460 words (11.2%)


Are the parameters 6 2 correct in this case?

Kind regards

Jan Lichtenbelt

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Stack Overflow

Post by kersing »

Hi Jan,

Are you sure you are interpreting the memory usage correct? The linker output suggests heap (RAM not used by global and local variables) is 76 bytes and at one point in the code you are allocating 75 bytes of it in one go. If you are not trying to allocate more before releasing the allocated 75 bytes there should be no problem... And if you are trying to allocate more of it while none is available you will not get it (return NULL from alloc)

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Stack Overflow

Post by Jan Lichtenbelt »

Hi Jac,

That is correct. I miss interpretated it. That means my problem is something else. Not stack overflow.

Kind regards

Jan Lichtenbelt

IVL
Posts: 17
Joined: Sat Sep 17, 2011 7:10 pm
Location: Belgium
Has thanked: 8 times
Been thanked: 5 times
Contact:

Re: Stack Overflow

Post by IVL »

Just for completeness and helping users how to implement BoostC software stack to avoid stack overflow :

1) In the FlowCode menu select Build, Compiler options
2) choose the tab Linker/Assembler
3) in the parameter box, scroll to the end and add the following parameter :
-swcs 6 2

This should do the trick, it did for me.

Regards,
Ivan

Post Reply