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 create an array index more than 256, in 24lc256

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







how to create an array index more than 256, in 24lc256
PostPosted: Sat May 01, 2004 2:51 pm     Reply with quote

Help!

how can i create an array index size more than 256 and without having an error: Subscript out of range.

i want to store data in 24lc256, i need the address(index) size around 1500, i just found that my array index go over 255 will not working, and i also get the info from the previous posting: if i use the keyword const, and then array will be placed in ROM. So the limit will be 256 locations.

so how can i create an array index more than 256, and store data in 24lc256?

Thanks!
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

Array size
PostPosted: Sat May 01, 2004 7:18 pm     Reply with quote

What processor are you using?

What CCS compiler version are you using?

Are you defining the index var as INT? If you are INT is only 8 bits which gives you 0-255.

Include the code for the definition of the array and the index variable.
Mk
Guest







PostPosted: Sat May 01, 2004 8:50 pm     Reply with quote

i am using a PIC16F1877A microcontroller, and my compiler is ccs c3.187

const char record[15][17] is ok,

but if i want the array size bigger, then i got an error message. i read the previous posting, if i use the keyword const, and then array will be placed in ROM. So the limit will be 256 locations.

so how can i create an array index more than 256, and store data in 24lc256?

how can i create an array has the size like: record[1500][17] store data in a 24lc256?

thanks!!
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Sat May 01, 2004 10:27 pm     Reply with quote

Keeping your data in an external EEPROM is not a problem. You can create a function to load 17 bytes at a time into the internal RAM as needed. You can also fill the EEPROM the same way. I don't know of any other way to do this with a PIC16 series chip.
Mk
Guest







PostPosted: Wed May 05, 2004 12:07 am     Reply with quote

So I have to use PIC18 series to solve this problem ? Crying or Very sad
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Wed May 05, 2004 12:59 am     Reply with quote

How much of the data do you want to transfer between the 24256 chip and the PIC at each go?
You are talking about 25500 bytes of data. There are a few ways of 'creating' an array larger than 256 locations on PIC16s, but you do not have enough RAM (or ROM) to keep all the 25500 bytes in the PIC.
Tell us what exactly you are trying to do.
Mk
Guest







PostPosted: Wed May 05, 2004 2:10 am     Reply with quote

hi, thank you for the reply!

i am trying to make a small portable items look-up device, if i enter an item code(4-digit numbers) from a keypad, then it will search the data which is stored in an external eeprom and display the result on a LCD output, since the items are around 1500, so i thought pic16fxxx plus an 24lc256 could handle this job, but now i am having a trouble to solve the array index size(more than 256), i need an array size like: record[1500][17] => 1500 items and one item has 17 chars.

so, is a pic18xxx can solve this problem? i am not quite familiar with this chip!

thanks advance! Embarassed
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Wed May 05, 2004 2:51 am     Reply with quote

Even on PIC18s it is not a good idea to transfer the whole 22500 byte of your EEPROM to your PIC's flash.
And you can't map your array on the EEPROM memory either in case you are wondering.
You don't need to define any big arrays at all. Do as Neutone suggested: Read the first 17 bytes, if they don't match your query then keep reading 17-byte packs until you find your data. This way you only need to define an array of 17 bytes and no more.
You can actually use some sort of clever indexing/hashing to speed up this sequential process.
Ttelmah
Guest







PostPosted: Wed May 05, 2004 3:44 am     Reply with quote

Mk wrote:
hi, thank you for the reply!

i am trying to make a small portable items look-up device, if i enter an item code(4-digit numbers) from a keypad, then it will search the data which is stored in an external eeprom and display the result on a LCD output, since the items are around 1500, so i thought pic16fxxx plus an 24lc256 could handle this job, but now i am having a trouble to solve the array index size(more than 256), i need an array size like: record[1500][17] => 1500 items and one item has 17 chars.

so, is a pic18xxx can solve this problem? i am not quite familiar with this chip!

thanks advance! Embarassed

The 'problem', only exists, because you are in a sense, thinking about it the wrong way. The external memory, is going to be used like the 'disk' on your computer. Hold only _one_ entry in the PIC, as say
char record[18];

Remember that a string record holding 17 characters, needs an 18th character for the null teminator. This may not apply, depending on how your 'record' is formatted.
Now do your calculation to work out which record you want. Multiply the result by 17 (the record size), and you know have the 'byte address' needed from the external storage device. Now read 17 bytes, starting at this address, into the 'record' variable.
You are currently trying to store the data twice. Once in the external memory, and a second copy in the internal program memory (this is what the 'const' keyword implies).
You need to work with a single 'record' in memory, and transfer the contents too/from the external storage device, just as you would to a hard disk.

Best Wishes
Mk
Guest







PostPosted: Wed May 05, 2004 10:32 am     Reply with quote

Thanks guys,

thank you for the tips, i am happy that u guys give me the tips which give me more hope and help too. then i don't need to find other different microcontroller.
i am not sure, is this the right way(by selecting a pic16xxx to do this job) to do or not, but at least now i know it can be done, i will try!!


Thanks again!! Wink
Joshua Lai



Joined: 19 Jul 2004
Posts: 42
Location: Malaysia, PJ

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

Wasting ROM
PostPosted: Sat Sep 17, 2005 3:04 am     Reply with quote

You have to understand the fundamental first. When you initialize an const array, the data is stored in the PIC program ROM. After that, the PIC transfer the data into the eeprom. But the data is still inside the PIC rom, this is wasting memory space.

Consider this: PIC16F876 only has 8kBytes rom, eeprom 24LC512 has 64kBytes memory, if I not mistaken.

Imagine how many times you need to program your PIC to fully store the eeprom?

You can use your programmer to program the eeprom, and the software, i think icprog support 24LC256 as well.

If you want to program the data into the PIC, then PIC stores it into eeprom, you may use a lot of array, for example, array1[256], array2[256]...
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