Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   memory management and organization (http://www.chiefdelphi.com/forums/showthread.php?t=23506)

WizardOfAz 09-01-2004 14:01

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

danielkitchener 09-01-2004 14:37

Re: memory management and organization
 
I believe the other 248 are to store our program on...however, I may be wrong. Hey, anything is better than PBASIC, and its small amount of space, less than 30 bytes...messed up a coupla good teams last year who decided to use counters for their autonomous, only to find it looping once the counter passed 254...

RoboCoder 09-01-2004 17:05

Re: memory management and organization
 
last year, though there still was the option of using words, for example, as a variable data type. We used this as a counter for auton mode, and had no problems as far as that goes.

Jay Lundy 09-01-2004 17:18

Re: memory management and organization
 
RAM is 2048 bytes (8 banks at 256 bytes each), but 256 bytes of that are used for SFRs (special function registers). These things control the settings for all the functions on the processor.

96 bytes of bank 0 and 160 bytes of bank 15 are used for SFRs. That leaves us with 1792 bytes of variable space.


All times are GMT -5. The time now is 00:32.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi