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

Large const long arrays

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



Joined: 02 Feb 2004
Posts: 17

View user's profile Send private message

Large const long arrays
PostPosted: Wed Dec 08, 2004 1:08 am     Reply with quote

Anyone have any ideas on the best way to implement a lookup table of 1024 long integers? I don't mind that this will take up 2k of rom space.

ccs doesnt seem to let me define a const table bigger than 128 longs. (256bytes). I would need 8 tables and i find that annoying, but if I have to i'll do that.

Any tricks or information would be great- Oh, im using a 16F88 with no external eeprom.
RossJ



Joined: 25 Aug 2004
Posts: 66

View user's profile Send private message

PostPosted: Wed Dec 08, 2004 1:46 am     Reply with quote

You could create the table using the #rom directive. Then read it using the read_program_eeprom() function. Also, if you only need the table to contain integers upto 16K (or +/- 8K) then you can save space by storing each value in a single program word (14 bits). Otherwise you will have to store it in two bytes and make two reads to retrieve the whole value.
j_s_connell



Joined: 02 Feb 2004
Posts: 17

View user's profile Send private message

PostPosted: Wed Dec 08, 2004 3:43 pm     Reply with quote

Thanks for the tip on using the single word, I hadn't thought of it like that- its perfect because i only really need like 10 bits of it. However, i'm not sure if using the on chip eeprom will work, as there is only 256 bytes (I need 1k program words or 2k bytes).
RossJ



Joined: 25 Aug 2004
Posts: 66

View user's profile Send private message

PostPosted: Wed Dec 08, 2004 9:15 pm     Reply with quote

If you take a look at the reference manual you will find that the read_program_eeprom() function reads PROGRAM memory (ie. flash in your case). To read the 256 bytes of DATA EEPROM you would use read_eeprom().
RossJ



Joined: 25 Aug 2004
Posts: 66

View user's profile Send private message

PostPosted: Wed Dec 08, 2004 9:50 pm     Reply with quote

Also, do you plan on putting signed values in the table? If so, you will need to sign extend the 14 bit value after reading them into an int16. This is done by testing if bit 13 is set and if so, setting bits 14 and 15 as well. Otherwise, the value read back will always be positive since bit 15 (and bit 14 for that matter) will always be returned as zero on a 14 bit PIC device.
Guest








PostPosted: Fri Dec 17, 2004 3:03 pm     Reply with quote

I read in another thread that it might be necessary to generate this table by hand (in hex), and insert it into the compiled hex file after the fact (as ccs cannot generate a table this large). Any idea what the asm would look like, and where i would insert it into the hex file?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 17, 2004 6:50 pm     Reply with quote

Anonymous wrote:
I read in another thread that it might be necessary to generate this table by hand (in hex), and insert it into the compiled hex file after the fact (as ccs cannot generate a table this large). Any idea what the asm would look like, and where i would insert it into the hex file?


Wouldn't be asm but what Ross stated:
Quote:
You could create the table using the #rom directive. Then read it using the read_program_eeprom() function. Also, if you only need the table to contain integers upto 16K (or +/- 8K) then you can save space by storing each value in a single program word (14 bits). Otherwise you will have to store it in two bytes and make two reads to retrieve the whole value.
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