|
|
View previous topic :: View next topic |
Author |
Message |
Mk Guest
|
how to create an array index more than 256, in 24lc256 |
Posted: Sat May 01, 2004 2:51 pm |
|
|
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: 1933 Location: Norman, OK
|
Array size |
Posted: Sat May 01, 2004 7:18 pm |
|
|
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
|
|
Posted: Sat May 01, 2004 8:50 pm |
|
|
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
|
|
Posted: Sat May 01, 2004 10:27 pm |
|
|
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
|
|
Posted: Wed May 05, 2004 12:07 am |
|
|
So I have to use PIC18 series to solve this problem ? |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Wed May 05, 2004 12:59 am |
|
|
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
|
|
Posted: Wed May 05, 2004 2:10 am |
|
|
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! |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Wed May 05, 2004 2:51 am |
|
|
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
|
|
Posted: Wed May 05, 2004 3:44 am |
|
|
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! |
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
|
|
Posted: Wed May 05, 2004 10:32 am |
|
|
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!! |
|
|
Joshua Lai
Joined: 19 Jul 2004 Posts: 42 Location: Malaysia, PJ
|
Wasting ROM |
Posted: Sat Sep 17, 2005 3:04 am |
|
|
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]... |
|
|
|
|
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
|