CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Strange allocation in flash memory

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

Strange allocation in flash memory
PostPosted: Wed Sep 03, 2014 1:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 03, 2014 1:43 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Sep 03, 2014 1:48 pm     Reply with quote

Yes, I supposed it but I hope somebody can explain me reasons
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Sep 03, 2014 2:11 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 04, 2014 11:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 05, 2014 7:34 am     Reply with quote

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).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group