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

ROM or CONST Pointer

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



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

ROM or CONST Pointer
PostPosted: Sat May 12, 2012 8:20 am     Reply with quote

Is possible use memcpy with a ROM POINTER ?

For example:

Code:
rom unsigned char matrix[4] = {1,2,3,4};
rom char *pointer;
char aux[2];

pointer = &matrix;
memcpy( aux, &pointer[ 2 ], 2 );
printf( %02X %02X\n\r", aux[ 0 ], aux[ 1 ] );


I test this and dont work.

I use the last version of compiler.

Best Regards,
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Sat May 12, 2012 6:09 pm     Reply with quote

ROM CONST is used in C18.


To understand how CCS deals with ROM based information, look at the CCS help .CHM file and the section Titled: Using Program Memory for Data.


Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun May 13, 2012 4:47 am     Reply with quote

With PIC16 and PIC18, rom pointers need to be emulated by the compiler, this works only with specific settings. With PIC24 and newer PCD versions, PSV (program storage visibility) allows a direct pointer access to ROM.

Your syntax is wrong however. You are writing
Code:
pointer = &matrix;
memcpy( aux, &pointer[ 2 ], 2 );


Should be changed to
Code:
pointer = matrix; // or &matrix[0], &matrix is usually understood too
memcpy( aux, pointer[ 2 ], 2 ); // you want to load the pointer value rather than it's address
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