Page 1 of 1

Stack Overflow

Posted: Fri Jun 22, 2012 3:21 pm
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

Re: Stack Overflow

Posted: Fri Jun 22, 2012 6:00 pm
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

Re: Stack Overflow

Posted: Fri Jun 22, 2012 8:02 pm
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!)

Re: Stack Overflow

Posted: Fri Jun 22, 2012 10:21 pm
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

Re: Stack Overflow

Posted: Sat Jun 23, 2012 2:38 pm
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

Re: Stack Overflow

Posted: Sat Jun 23, 2012 2:44 pm
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

Re: Stack Overflow

Posted: Sat Jun 23, 2012 6:32 pm
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

Re: Stack Overflow

Posted: Sat Jun 23, 2012 7:30 pm
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

Re: Stack Overflow

Posted: Sun Aug 19, 2012 9:19 am
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