View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Locating and Reducing RAM Usage |
Posted: Mon Dec 20, 2010 10:02 am |
|
|
I am consolidating several stand-alone test programs into a single on an 18F6627 using 3.249. I am running into problems during compilation due to not enough RAM. When I look at the symbol file, these are the culprits:
Code: |
000 @SCRATCH
na disk_read.SectorNumber
na disk_read.SectorCount
na SD_cmd.@SCRATCH
na SD_receive_data.@SCRATCH
na SD_write_data.@SCRATCH
na disk_write.@SCRATCH
na disk_read.@SCRATCH
na serial_isr.@SCRATCH
na serial_isr2.@SCRATCH
001 @SCRATCH
002 @SCRATCH
003 @SCRATCH
...
...
FEF INDF0
FF0 INTCON3
FF1 INTCON2
FF2 INTCON
FF2 INTCON1
*** na indicates variables that would not fit into memory |
My first assumption is, there is a problem with organization and not memory size?
It looks like I'm into some of the deeper, darker recesses where I've never been. Can anyone offer any guidance?
Thanks,
John
EDIT:
I have tried: #device *=16 without success. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon Dec 20, 2010 10:29 am |
|
|
None of those are the 'culprits'......
The last few are hardware registers on the chip, and the first set are scratch (temporary) locations. Nothing of any size shown here.
You are looking at large arrays, strings, etc., as the thinks that 'drink' memory.
*=16, makes no difference on a PIC18. These chips address all their memory OK without this.
Best Wishes |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Mon Dec 20, 2010 10:42 am |
|
|
I have been looking at the symbol file and finding the variables that use large chunks and reducing them. That seemed to work. The major user is the SD file system and what has turned into, several files being declared to the tune of 512B each. So, I guess now it's time to sharpen the pencil and figure out what's necessary and what isn't.
Thanks for the info,
John |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon Dec 20, 2010 11:02 am |
|
|
Given that the sector on a SD card, is 512bytes, and must be written as one 'lump', of course' the buffers are 512bytes in size.....
This is where careful management of your other use of memory, or possible 're-using' the same area for other things when not talking to the card, becomes necessary.
Best Wishes |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Mon Dec 20, 2010 11:13 am |
|
|
Ttelmah wrote: | This is where careful management of your other use of memory, or possible 're-using' the same area for other things when not talking to the card, becomes necessary. |
I had an extremely competent programmer (much more so than I) write some of the code. However, he was a large embedded system guy, so I think he wasn't quite as 'aware' of the memory that was being used up. I've found three different file structures declared at 512B each. I'm checking now to see if I can manage with just one.
Thanks again,
John |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Mon Dec 20, 2010 5:14 pm |
|
|
jecottrell wrote: |
I had an extremely competent programmer (much more so than I) write some of the code. However, he was a large embedded system guy, so I think he wasn't quite as 'aware' of the memory that was being used up. I've found three different file structures declared at 512B each. I'm checking now to see if I can manage with just one.
|
It's a common thing I find with people who think all "programmers" are the same.
People who work with "linux" or "windows CE" are typically not at the same level as folks who work with these little itty bitty micro's with 1024K of flash and 35 bytes of RAM... hahaha
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Tue Dec 21, 2010 8:22 am |
|
|
bkamen wrote: | People who work with "linux" or "windows CE" are typically not at the same level as folks who work with these little itty bitty micro's with 1024K of flash and 35 bytes of RAM... hahaha |
Amen. For the last 10 months I've been primarily cleaning up a monumental mess created by a revolving-door's worth of pure "programmers" over the last 5-6 years. None of them had any electronics knowledge and based on the code I've inherited, they obviously had no idea what was going on "under the hood"; ie that floats in an 8 bit micro are generally a bad idea and writing 3 pages to program EEPROM "bricks" the micro for about half a second. |
|
|
|