|
|
View previous topic :: View next topic |
Author |
Message |
cfernandez
Joined: 18 Oct 2003 Posts: 145
|
ROM or CONST Pointer |
Posted: Sat May 12, 2012 8:20 am |
|
|
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
|
|
Posted: Sat May 12, 2012 6:09 pm |
|
|
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
|
|
Posted: Sun May 13, 2012 4:47 am |
|
|
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 |
|
|
|
|
|
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
|