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

How to use constant arrays as parameters for a function?

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



Joined: 24 Apr 2025
Posts: 5

View user's profile Send private message

How to use constant arrays as parameters for a function?
PostPosted: Thu Jul 24, 2025 9:49 am     Reply with quote

to save RAM space I saved a some arrays in the ROM as :

#define MAXBUFFER 64
unsigned int32 const array_rom1[MAX_BUFFER];
unsigned int32 const array_rom2[MAX_BUFFER];
unsigned int32 const array_rom3[MAX_BUFFER];

How can I use those constant arrays as parameters for a function?

void function(int32 *aux);

writing

function(array_rom1);

complirer doesn't report any error but the data are wrong

thank you
Ttelmah



Joined: 11 Mar 2010
Posts: 19928

View user's profile Send private message

PostPosted: Fri Jul 25, 2025 2:00 am     Reply with quote

What chip?.
It makes a huge difference.
What compiler version?.
Also makes a difference.

The big problem here is trying to use a pointer to ROM. This has been
discussed here many times. The point is that pointers are to the RAM, and
this is a different memory space to the ROM. This is fundamental to the
PIC's Harvard architecture,
You are telling the routine you are passing a pointer to RAM.

Have a look at this thread:
[url]
https://www.ccsinfo.com/forum/viewtopic.php?t=35864
[/url]
You can also switch how const is handled.#DEVICE CONST=ROM, will
make const declarations be handled like ROM declarations.

On the 16bit PIC's you can create a window between the ROM and RAM.
This is 'PSV'. can be enabled with #device.
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