View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19459
|
|
Posted: Fri Nov 20, 2015 9:03 am |
|
|
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'!... |
|
|
rjenkinsgb
Joined: 03 Apr 2018 Posts: 4
|
|
Posted: Wed Nov 01, 2023 4:34 am |
|
|
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
|
|
Posted: Wed Nov 01, 2023 8:03 am |
|
|
memcpypgm2ram is a MicroChip C18 function not a CCS function.
Worth perhaps saying that strcpy, merrily handles copying a string from
ROM to RAM. |
|
|
|