PDA

View Full Version : Array problem (18F2550)



Ronald123
- 8th January 2008, 18:15
I use the 18F2550
The configuration settings of my application are arranged in de Eeprom of the PIC. At the beginning of my application the complete Eeprom information is copied (read) to an Array (255).

Part of my application

DATAEEPROM VAR BYTE[255]
I var byte
I=0
FOR I=0 TO 255
READ I,DATAEEPROM[I]
NEXT I

I found out the the information in DATAEEPROM[0] is always 0. However the data at this position is 255 (FF). I found out the location 0 of the Array is causing the problem.
when I change
READ I,DATAEEPROM[I]
to
READ I,DATAEEPROM[I+1]
however then I'll get problems with the last position.

Does somebody knows what I'm doing wrong?

mister_e
- 8th January 2008, 18:29
i+1 will give 256, which is almost impossible to fit in a byte variable, even if you bend the edges of it ;) maybe 0+i could work better. Even with it... you defined a 255 bytes array while your read 256 value. you should define a 256 bytes array size.

Out of curiosity, why are you using an array to hold the whole EEPROM ?

Ronald123
- 8th January 2008, 18:47
I do that because I think that accessing information with an array is quicker than than accessing information of the PIC eeprom. I have not found information whether I'm right or wrong.
Within my application (PLC) information from the eeprom is read into a var more than 1000 times per second. I thought the application will be faster to use an Array for this.