View Single Post
  #8   Spotlight this post!  
Unread 12-01-2007, 00:11
Ken Streeter's Avatar
Ken Streeter Ken Streeter is offline
Let the MAYHEM begin!
FRC #1519 (Mechanical Mayhem)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Team: Milford, NH; Me: Bedford, NH
Posts: 470
Ken Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond repute
Re: How much memory is there really?

Quote:
Originally Posted by PhilBot View Post
I just started trying some algorithms for our arm, and ran into some memory problems. I want a big lookup array. ...

so I tried declaring the array as "rom" to see if I could use code space for my lookup table (since it will never change). ...
Thanks for sharing the tip on using "rom" space for constant lookup tables!

Quote:
Originally Posted by Mark McLeod View Post
We have three types of memory...

128,000 bytes program space
3936 bytes variable space (less the PROTECTED, etc. areas listed in 18f8722.lkr)
1024 bytes EEPROM

The default is to put variables into the 3936 byte variable space where your code can modify the values while it's running. There is a further limitation on the variable space due to how the linker has the space blocked out.
You are only able to declare 256 bytes of variable space in any one MPLAB project file.
Thanks for the information on the amount of memory available in each type of space! It's nice to have the quick summary as well as the pointer to the description in the manual.

An additional approach I might mention is one that we used last year in order to be able to have declarations of more than 256 bytes of variable space within a single MPLAB file -- we made use of the pragma directive to explicitly switch memory sections.

Code:
#pragma idata mem_section_1
  // put up to 256 bytes of declarations here

#pragma idata mem_section_2
  // put up to 256 more bytes of declarations here

#pragma idata mem_section_3
  // put up to 256 more bytes of declarations here

#pragma idata
  // actual code goes down here
__________________
Ken Streeter - Team 1519 - Mechanical Mayhem (Milford Area Youth Homeschoolers Enriching Minds)
2015 NE District Winners with 195 & 2067, 125 & 1786, 230 & 4908, and 95 & 1307
2013 World Finalists & Archimedes Division Winners with 33 & 469
2013 & 2012 North Carolina Regional Winners with teams 435 & 4828 and 1311 & 2642
2011, 2010, 2006 Granite State Regional Winners with teams 175 & 176, 1073 & 1058, and 1276 & 133
Team 1519 Video Gallery - including Chairman's Video, and the infamous "Speed Racer!"