Pages: 1 [2]   Go Down
Author Topic: What is the default stack size for function calls?  (Read 1766 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 70
Posts: 3727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 70
Posts: 3727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink

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.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 173
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)!
Logged

Pages: 1 [2]   Go Up
Jump to: