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 support@ccsinfo.com

Using rom as constant
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19459

View user's profile Send private message

PostPosted: Fri Nov 20, 2015 9:03 am     Reply with quote

Obviously suffering from BDS (bracket deficiency syndrome). I've had a couple of little typos in the last couple of days. Teach me to type things directly, rather than testing them first as I normally do for more complex stuff. Also makes sure that the reader is 'on their toes'!... Twisted Evil
rjenkinsgb



Joined: 03 Apr 2018
Posts: 4

View user's profile Send private message

PostPosted: Wed Nov 01, 2023 4:34 am     Reply with quote

Ttelmah wrote:


Problem is that memcpy as written for the PIC24, is explicitly written to _only_ access RAM. It uses the direct RAM to RAM transfer ability, and this is why the manual says it only copies to/from RAM. strcpy, is overloaded to handle ROM pointers.

Just do your own version of memcpy, to handle ROM data. Something like:
Code:

void rommemcpy(unsigned int8 * dest,rom char * source, unsigned int16 count)
{
   if (count==0 return;
   do {
   *dest++=*source++;
   } while (--count);
}




Thank you! I just discovered this solution after several hours of hair-tearing frustration & caffeine overload!

It appears memcpy still does not work with const *
(on PCD 5.115 with dsPIC33EP512GP502)

The manual reads as if it copies to a destination in RAM, it's not clear that the source can only be RAM also.

One of the other posts I found while searching shows an internal compiler function?? that appears to do this?

memcpypgm2ram()


It would be useful to have that documented in the manual, if it part of the compiler - or a new dedicated function for this added?

[hint!]
Ttelmah



Joined: 11 Mar 2010
Posts: 19459

View user's profile Send private message

PostPosted: Wed Nov 01, 2023 8:03 am     Reply with quote

memcpypgm2ram is a MicroChip C18 function not a CCS function.

Worth perhaps saying that strcpy, merrily handles copying a string from
ROM 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
Goto page Previous  1, 2
Page 2 of 2

 
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