Go Down

Topic: What is the default stack size for function calls? (Read 2088 times) previous topic - next topic

cappy2112


That function tells you how much space there is left between the top of the stack and the bottom of the heap. If that's really -114, as I surmised earlier, your heap and stack are trying to use the same memory. Very bad things will result.


Yep- I kinda guessed that a negative value wouldn't be good ;-)

I've found the location of the .elf file, copied it to the directory where the avr tools are, and did an avr-objdump on the elf file.

I'm looking at the assembly + source listing now.

In general- is there a link for "Good Practices" for Arduino programming?
When I started my project, I had everything laid out on paper- but didn't give much thought to the 2K ram limit.

I'm sure there are some sensible ways to cut back on my over-usage of that 2K memory.
Thanks

wildbill

Look at progmem - see what constant strings you can keep in flash until they're needed.

If you need buffers, make sure they're no bigger than needed - not 1024 just in case. This is rather old school compared to anything you might do on a PC these days  ;)

wildbill

Look at progmem - see what constant strings you can keep in flash until they're needed.

If you need buffers, make sure they're no bigger than needed - not 1024 just in case. This is rather old school compared to anything you might do on a PC these days  ;)

cappy2112


Look at progmem - see what constant strings you can keep in flash until they're needed.

If you need buffers, make sure they're no bigger than needed - not 1024 just in case. This is rather old school compared to anything you might do on a PC these days  ;)


This is where I am now

Quote
avr-size myproject.cpp.elf
   text    data     bss     dec     hex filename
   7240     598     380    8218    201a myproject.cpp.elf


freeMemory() is now reporting 898 in the function I suspect that has problems.

But that function calls Serial.print - and nothing is being displayed.
I may still be short on SRAM space.

cappy2112


avr-size myproject.cpp.elf
   text    data     bss     dec     hex filename
   7240     598     380    8218    201a myproject.cpp.elf


freeMemory() is now reporting 898 in the function I suspect that has problems.

But that function calls Serial.print - and nothing is being displayed.
I may still be short on SRAM space.
[/quote]

Ok- I'm getting 972 from freeMemory() now- looks like I'm back in business.
My function is executing normally now. I'm seeing the output of Serial.print.

I did all the opti by hand, turned some functions into macros so that code will be inline, instead of on on the stack after another function call.
I think I'll go thru and move some strings to progmem, to give me some extra room.

Thanks to everyone who replied (to all the threads)!

Go Up