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

Pointers to an array

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



Joined: 18 Nov 2013
Posts: 159

View user's profile Send private message

Pointers to an array
PostPosted: Mon Nov 30, 2020 10:41 am     Reply with quote

Can I create an array of 32-bit integers and assign that to a pointer? I don't have hardware to test this right now, and when I tried it a few years ago it didn't work. It compiled but the program didn't do what I wanted.
Example:
Code:

signed int32 *pData[];
const signed int32 mydata[] =
{
  0x01000002,
  0x02000001,
  0x03000046,
  0x05000390,
  0x05000000,
  0x06002F4A,
  0x0700054D,
  0x08C9BEFF,
  0x09573FFF, 
  0x0A002047,
  0x0B0F8061,
  0x0F000081,
  0x04200000 
};
void main()
{
  byte len = sizeof(mydata) >> 2;
  pData = mydata;
  Dosomething(pData, len);
}

void Dosomething( int32 *d, byte num )
{
}

I'm using v5.097 of PCWH and a 12LF1552 pic.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Mon Nov 30, 2020 11:51 am     Reply with quote

Historically, the problem would have been this one word. 'Const'.
The problem is that the PIC is a Harvard architecture processor. On this
the RAM, and program memory are in different memory spaces. Const
puts the variable into the program memory space. Result a RAM pointer
won't actually point to it....
Now you can use ROM instead of const, which tells the compiler to store
the data so a ROM * pointer can be constructed to it. However you do have
to declare your function so it expects a ROM * pointer.
If you look at my SSD1306 driver in the code library this uses ROM *
pointers, so you can see how these can be used. Beware though that
CCS 5.096 has an issue with these (fixed in 5.097, and OK on earlier
releases).
SeeCwriter



Joined: 18 Nov 2013
Posts: 159

View user's profile Send private message

PostPosted: Mon Nov 30, 2020 12:04 pm     Reply with quote

I will check it out. Thanks.
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