View previous topic :: View next topic |
Author |
Message |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
Strange allocation in flash memory |
Posted: Wed Sep 03, 2014 1:23 pm |
|
|
Hy to all,
I compile my firmware for PIC18F67K22 with CCS compiler V4.135.
I discover ccs allocate my program from 0x00 to 0x0F970 and 0x10000 to 0x10820. CCS left memory from 0x0f971 to 0x0FFFF free without I decided it. If I delete some lines of program CCS allocate in flash without left free space from 0x0000 to 0x0ff66.
I don't realize why CCS allocate flash in this way because I don't reserved any free space.
Somebody can help me to understand why ?
Fabri |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 03, 2014 1:43 pm |
|
|
It looks like CCS doesn't want a function to cross a 64K boundary.
If the function doesn't fit in the remaining space in the 1st 64K block,
CCS starts the function at the beginning of the 2nd 64K block. |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Wed Sep 03, 2014 1:48 pm |
|
|
Yes, I supposed it but I hope somebody can explain me reasons |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Wed Sep 03, 2014 2:11 pm |
|
|
From what I understand a complete function must be contiguous and within a page boundary. This allows the compiler to create tight, fast code to access the function.
Now there's no _technical_ reason why a function couldn't 'span' the page boundary and other compilers( PC for instance) will allow it. The problem is the 'overhead' in figuring out what part of the function is in which page. It get's very 'messy' especially with a complicated function !!
CCS did a compromise(as everyone does...). Now if you want to maximize the code space, you can 'rearrange ' the functions you use and you might get more in the 1st page. Frankly unless you're running out of space, it's not an issue.
hth
jay |
|
|
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Thu Sep 04, 2014 11:54 pm |
|
|
At the moment it isn't a real problem. Firmware work fine.
CCS compiler start at 0x10000 with "main". In my application "Main" is the last part of firmware and bootloader is in the top of flash. I must take care only when I'll export firmware to use with bootloader May be CCS consider to haven't any routine across the first 64K first page ?
Is this really a possible reason ? |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1349
|
|
Posted: Fri Sep 05, 2014 7:34 am |
|
|
You can tell your program how to avoid the bootloader using things like #build and #org (see the manual or do some forum searching for explanations). |
|
|
|