Replacing an ARRAY with EEPROM write to save space?

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005

    Question Replacing an ARRAY with EEPROM write to save space?

    Hi folks:

    I have a couple big arrays in a program, and I am running out of codespace on the 16F88. I'd like to use EEPROM to store the data vs an array to free up some space, but am unsure of the approach to be taken. I've played with WRITE and READ, but not in a loop that did anything...

    An example array is as follows:

    1. The variables:
    foo.array var byte[34] ' the array that will contain all the data

    2. Program:

    ' get data - read from serial pin data that comes in every second

    Serin2 Cpinin,84,1000,nodata,[wait($02,$47), STR foo.array\34]

    ' Calculate the variables from the array

    ' read data for temperature which is in hex
    SSD4= (foo.array[24]>>4)
    SSD3= (foo.array[24] & $f)
    SSD2= (foo.array[23]>>4)
    SSD1= (foo.array[23] & $f)

    Dec_temp=(ssd4*4096)+(ssd3*256)+(ssd2*16)+ssd1 ' convert to decimal


    ' write out the new data to display

    serout2 cpinout, 84,["Temp: ",Dec_temp]

    'Loop back and read the next data from serial again..

  2. #2
    Join Date
    Jul 2003


    Arrays don't use program memory. They are created in RAM (shown as SRAM in your datasheet).

    PBP system variables can require up to 24 bytes for the 16F family & 26 bytes for the 18F family. How many are actually used depends on the PBP command used in your program, the target device, and library routines included at compile time, etc...

    Your array of 34 bytes + PBP max system vars is only 58 bytes. For the 16F88 you have 368 bytes - so you still have 310 bytes RAM left to play with.

    You can store information in data EEPROM, or flash program memory, but you can't work with EEPROM like you can with "variables" in a RAM data array.

    I.E. you can read data into your RAM array, then stash it in EEPROM, but you can't read your data directly into a string "STR foo.array\34" into EEPROM.

    tech at

  3. #3
    Join Date
    Feb 2005

    Red face

    Thanks much! This is good to know!

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 15:46
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 04:17
  3. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 15:19
  4. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 07:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 20:59

Posting Permissions

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