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

Penalty for accessing constant strings stored in ROM

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



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Penalty for accessing constant strings stored in ROM
PostPosted: Sat Jan 09, 2016 2:45 am     Reply with quote

Folks,

I've noticed that standard string functions ( strncmp(), for example) take longer to execute when one of the parameters is a constant string stored in Flash. I have the pass strings in RAM directive. Is there a time penalty for accessing constant strings that are stored in Flash?

In the meantime, I'll do a workaround where I temporarily "cache" the strings in RAM for quick access. I happen to have enough RAM for that.

Cheers,
- Nick and his PIC18LF4550
_________________
Read the label, before opening a can of worms.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Sat Jan 09, 2016 4:16 am     Reply with quote

Yes. Of course.....

Data has to be read from the ROM to RAM, and then accessed in the RAM.
Because the 'pass strings' operator, is trying not to use too much RAM, it only uses a tiny buffer, so several successive reads.
If you instead just copy the string to RAM, only a single RAM access has to be done.
TANSTAAFL.

Editing.

This is why I don't use pass_strings=IN_RAM, but instead keep with having to use the separate const or ROM if I want to use pointers. If I want to access something in RAM I just copy it to RAM....
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