Shop OBEX P1 Docs P2 Docs Learn Events
Doubt on data storage on EEPROM — Parallax Forums

Doubt on data storage on EEPROM

TAMILTAMIL Posts: 11
edited 2008-04-12 01:58 in BASIC Stamp
controller used:BS2P40
EEPROM 8 x 2KByte

hi,
My question is related to data storage into EEPROM.
By using DATA directive, we can download data along with program. But, what I would like to know is
how to use the data storage in EEPROM once the program is loaded?
is it possible to use WRITE/READ commands for loading a bulk of data (data range may be 2kbits to 10kbits).
is there a best way to do it?

Comments

  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-11 18:41
    It's not difficult to do, but there are a few different ways of doing it depending on what you are writing. What kind of stuff do you want to write?
  • TAMILTAMIL Posts: 11
    edited 2008-04-11 18:45
    the input data is a stream of bits. range from 2k to 10kbits. and I want to download it in one go.

    Post Edited (TAMIL) : 4/11/2008 6:57:34 PM GMT
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-11 19:26
    The data stream will have to be broken down some- there is not enough ram available to buffer that much data prior to writing it. You would have to download some, write it, then download more, write it, and so on.
  • TAMILTAMIL Posts: 11
    edited 2008-04-11 20:03
    what is the maximum data size that can be written at a time. if it is a word(2 byte)? how long it can take to finish of downloading 2Kbits?
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-11 20:48
    I figured that would be your next question! Unfortunately I can't find that answer, and it probably isn't a simple answer anyway. Unless I am mistaken, the data will be stored in ram when it is downloaded. How much ram you have available will vary depending on the number of variables used as well as what your stamp is doing- it has to have some free space to "work out" any calculations you have it doing. My GUESS is that the stamp would be very content to download 1000 bits (just a made up #) of information into a 100 bit area, writing over each previous 100 bit section without a care in the world, so at the conclusion you would only have bits 900-1000 in ram. I may be wrong about that. So anyway, I think I would try chopping it up into, say, 4-8 words at a time.

    As for the time it will take, I can give you an estimate. A section of my code writes all 0's to 1k of my eeprom to clear it. That process takes about 3 seconds.

    Are you concerned about time because this is an often repeated process? You only have a limited number of write cycles before your eeprom is burned out.
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-11 21:18
    Oh, the BS240 is 3 times as fast as mine (BS2e) so your time could be significantly less.
  • ZootZoot Posts: 2,227
    edited 2008-04-11 22:56
    You can write as much as you like to the onboard EEPROM but only a byte or Word at a time. For the INPUT stream buffer, don't forget you have scratch pad ram, so you could buffer up to 128 bytes + more in regular ram, but that's still less then 1kbit. So whatever device is sending the bitstream will need to be setup to pause to let the Stamp write and flush it's buffer.

    Say you have the other device send 100 bytes at a time, then wait 300ms (~3ms per byte write)....

    i VAR Byte
    ioByte VAR Byte
    eeAddr VAR Word
    Main:
      SERIN Pin, Baud, [noparse][[/noparse] SPSTR  100 ]  ' capture 100 bytes to sram, registers 0-99
      FOR i = 0 TO 99
         STORE eeAddr >> 11 + 1 ' store in slots 1-7 
         GET i, ioByte ' get each byte in buffer
         WRITE eeAddr, ioByte ' write the byte
         eeAddr = eeAddr + 1  
       NEXT
       GOTO Main ' next 100 bytes
    
    



    You could also put a "wait" into the serin and have the other device send a header indicating the start of a byte stream. You could also consider using SEROUT to let the device know that the Stamp has written the 100 bytes and that it's OK to send the next stream. Hopefully this helps some smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2008-04-11 23:05
    The Stamp WRITE command does one byte at a time, and it finishes writing one byte before moving on to the next. That can take up to 5 milliseconds per byte, but it is usually somewhat faster. jmalasia reported 3 seconds to write 2kbytes, which would be 1.5 milliseconds per byte including processing time. The BS2p will not be much faster than the other Stamps, because it is determined by the speed of the eeprom, not the speed of the Stamp. If you use an external eeprom, you can write much faster, because you can send it 32 bytes and then write all of them as a page in the same time it takes to write one byte. There are other memory technologies that are faster.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • jmalaysiajmalaysia Posts: 97
    edited 2008-04-12 01:58
    Actually it was 3 seconds for 1kbyte... that is just an estimate though. I have a "wait" lamp that illuminates while the memory is being cleared and I'm just estimating it at 3 seconds.
Sign In or Register to comment.