View Single Post
  #1   Spotlight this post!  
Unread 09-01-2004, 14:01
WizardOfAz's Avatar
WizardOfAz WizardOfAz is offline
Lead Mentor
AKA: Bill Bennett
FRC #1011 (CRUSH)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Tucson, AZ
Posts: 101
WizardOfAz will become famous soon enough
Send a message via AIM to WizardOfAz
memory management and organization

They say we only get 1800 bytes of variable space, but the chip has 2048 bytes of ram. Anybody know where the other 248 bytes went? I guess they are reserved for some special purposes, or already used up by the loader or other control functions, but if anybody knows the real answer, I'd like to hear it.

As I understand it, local variables and function parameters, unless declared static, are allocated on the software stack, which uses ram. This means the sum of all local vars and parameters for all functions on the call stack at any one time have to fit on the stack. The stack is 256 bytes in the default linker script (18F8520i.lkr), so seems like this could get used up real easy.

Anybody know what happens if you blow the stack? Does the PROGRAM STATE LED light up to warn you that it happened, or do you just start getting hard to explain bad behavior?

I get most of this, but if anyone would care to provide a good summary of how the various parts of ram are managed and tips and tricks for making good use of it, that would be great. Or pointers to where in the books to read, or white papers, or app notes, and so on.

Thanks
Bill