Array problem (18F2550)


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Posts
    9

    Default Array problem (18F2550)

    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?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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 ?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    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.

Similar Threads

  1. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  2. 18f2550 USB OSC Problem
    By serkanc in forum USB
    Replies: 10
    Last Post: - 29th October 2008, 20:52
  3. Problem with A port on 18F2550
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 9th May 2007, 22:59
  4. array problem
    By ro37bis in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 16th September 2006, 21:12
  5. Problem with bit array
    By Dick M in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th May 2005, 17:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts