Shop OBEX P1 Docs P2 Docs Learn Events
How do you BACK UP user input data when prop is turned off? — Parallax Forums

How do you BACK UP user input data when prop is turned off?

DavidMDavidM Posts: 626
edited 2007-03-15 15:53 in Propeller 1
Hi,

How do you allow a user to input data and have the PROPELLER chip remember that data when the prop is turned off?

I understand that I load the chip with my spin code ( in the EPROM) , and that variables can be set/changed during execution, But in my current project I need the user to create/edit some data ( that is inputed via an LCD/ INPUT buttons) and have that data stored/changed, but especially kept when the prop is turned off

regards

Dave M

Comments

  • mahjonggmahjongg Posts: 141
    edited 2007-03-14 11:35
    Use the serial (boot) EEPROM beyond the first 32K with modified I2C drivers. A lot of people do this. For example femtoBasic has routines to store data in the EEPROM "above" the area used to boot the propeller.

    Mahjongg
  • DavidMDavidM Posts: 626
    edited 2007-03-14 11:40
    Hi Mahjohngg,

    I need a little more info than that,

    OK I can store the info in the area above 32k of the eprom. that good.

    But what commands put the data in there ?

    Dave M
  • DavidMDavidM Posts: 626
    edited 2007-03-14 11:47
    I just read this in the manual ..

    Do the commands BYTEFILL, WORDFILL & LONGFILL serve this purpose?

    I need only to store small values..


    Dave M
  • simonlsimonl Posts: 866
    edited 2007-03-14 11:52
    DaveidM: I've not done any EPROM data saving yet, but Mahjongg is correct - FemtoBasic has the routines you'll need (though Mike has done other I2C routines too). If you look at FemtoBasic, I think (I've not looked!) you'll see object(s) that you'll be able to use.

    One thing to watch-out for: when you re-program the PChip, it re-writes all of the EPROM. Actuall, having said that, it _may_ only be the first 32K that gets blatted - anyone know for sure?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,

    Simon

    BTW: I type as I'm thinking, so please don't take any offense at my writing style smile.gif

    www.norfolkhelicopterclub.co.uk
    You'll always have as many take-offs as landings, the trick is to be sure you can take-off again ;-)
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-03-14 11:59
    Dave,

    You comunicate with the EEPROM using I2C routines:

    en.wikipedia.org/wiki/I2c

    They are available in the objects exchange but also check out this thread:

    http://forums.parallax.com/showthread.php?p=626983

    Graham
  • DavidMDavidM Posts: 626
    edited 2007-03-14 12:00
    Why do you need i2c ?

    Do the commands BYTEFILL, WORDFILL & LONGFILL do this?

    Dave M
  • DavidMDavidM Posts: 626
    edited 2007-03-14 12:27
    Ok, I did some more reading,

    the commands BYTEFILL, WORDFILL & LONGFILL only work with RAM not the EPROM,

    The eprom is connected to the PROP via an i2C line, So I need i2c code to read & rwrite to the eprom and I should use the BYTEFILL, WORDFILL & LONGFILL to modify the RAM with the data that is read.

    Correct?

    I have download the simple basic i2c spin code, I will have a read.


    dave m
  • DavidMDavidM Posts: 626
    edited 2007-03-14 12:41
    I have read some of the i2c spin code,

    heres what I plan to doo

    1) I2CSTART
    2) I2C WRITE
    3) I2CSTOP

    When the user changes some data , that data will be written to the eprom after it is written to the main ram, then when the power is turned of then on again all of the eprom, including the user data is put into the main ram?

    Is my understanding of this correct?

    dave M
  • bambinobambino Posts: 789
    edited 2007-03-14 12:56
    Dave,

    The First 32k of EEPROM is the data that gets loaded into RAM on startup. Any thing you write to the upper 32k while the prop is running using the I2C routines will be there when you reboot. Provided you wrote to EEPROM at addresses that are not being used by your main program, in which case your prop may excert unwanted behavior. As mentioned, if you have an EEPROM greater than 32k then writting to addresses above 32k will not be loaded into ram by the boot loader. You will have to use the I2C routines to get this data.

    Regardless, If you do not have another prop or microcontroller on the I2C bus there is no way of loading EEPROM from the programming connection or alternate UART to another smart device. Loading of the EEPROM is done with the I2C only.

    There may be devices EEPROM in nature that interface via a UART( Though I do not know of any).

    MisRead your post Dave. No, just turning off and on will not place data that is in ram into your EEPROM. The I2C routines 1,2,and3 did that already. What you wrote with the routines will be loaded when you reboot.

    Post Edited (bambino) : 3/14/2007 1:01:59 PM GMT
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-03-14 13:32
    As they say in the old programming westerns, "read first, ask questions later".

    If you put your data in the first 32k of the eeprom then it will get loaded into the main RAM when the power is turned on but you will need to be careful not to over write your program. I'm not sure of the best way to code it without sitting down and thinking about it.

    If you put your data in the eeprom beyond the first 32k then you can simply use the I2C routines again but this time you will read the data.

    Graham
  • BergamotBergamot Posts: 185
    edited 2007-03-14 13:56
    for(int i = 0; i < 10; i++)
    {
        step();
    }
    draw();
    
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-14 14:39
    daveM,
    EEPROMs are a bit more complicated than Start/Write/Stop. You have to send an address to the EEPROM, then the data. If you're reading, you have to send the address, then reselect the device for a read transfer. Please use the routines in either "Basic I2C Driver" or in "i2c Object and examples" from the Propeller Object Exchange. These have specific routines for reading/writing EEPROM locations that take care of this detail.

    If you only have 32K for a boot EEPROM as in the Demo Board, you can use the upper end of the EEPROM for data storage as long as you understand that the whole first 32K will be erased when you download a program using the Propeller Tool. If you have a Proto Board, there's a second 32K that is not touched unless you access it yourself. You can always add extra EEPROM either to the boot EEPROM I/O pins (28/29) or to any other pair of pins.
  • IWriteCodeIWriteCode Posts: 16
    edited 2007-03-14 14:47
    A good source of information is the datasheet of the 24LC256: http://ww1.microchip.com/downloads/en/DeviceDoc/21203N.pdf
  • cgraceycgracey Posts: 14,133
    edited 2007-03-14 16:32
    Another thing to keep in mind is that doing an @variable will return the address of a variable in RAM. If you write to the EEPROM at that same offset, the value will be restored next boot-up.

    The first 32KB of EEPROM contains the exact image, bit-for-bit, that gets loaded into the 32KB SRAM on boot-up. So, you can make variables declared·by either VAR or DAT statements non-volatile by updating them at identical offsets in the EEPROM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • inserviinservi Posts: 113
    edited 2007-03-14 16:44
    Hi Chip,

    That is a very good tips.

    dro.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    in medio virtus
  • OwenOwen Posts: 100
    edited 2007-03-14 21:10
    does the 24LC256 actualy have 256k that the propellar can access? I'm a bit confused as to what 32k x 8 means in this context. does this mean that I could use the 24lc256 and have 224k for non propellar program memory acecable with I2c?

    Owen
  • IWriteCodeIWriteCode Posts: 16
    edited 2007-03-14 21:14
    It's 256 Kbits, which is 32 KBytes. An earlier mentioned option is to add another EEPROM, with a different address.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-14 21:51
    The largest EEPROMs available currently are the Atmel 24LC1024 (1M bits = 128K x 8) and the Microchip equivalent which is not at all identical. The Atmel part is used in the Hydra and a smaller part (the 24LC512 = 64K x 8) is used on the Propeller Protoboard. The 24LC1024 would leave you with 96K bytes of space not used by the Propeller and the 24LC512 would leave you with 32K bytes.

    You can have two 24LC1024 (like the Hydra with its memory expansion card) for a total of 256K bytes. You can actually have up to eight 24LC512 because of the way the parts are wired for a total of 512K bytes.
  • OwenOwen Posts: 100
    edited 2007-03-14 22:02
    what's so diferent with the microchip equivalent? would it still be usable? I cant seem to find the atmel 24lc1024 on digikey or mouser but i can find the microchip 24lc1025.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-03-14 22:10
    Because the address word is 16 bits this only permits memory sizes up to 64K addresses (64KBytes for byte addressable memory as with the EEPROMS). So the extra bit required to address the extra 64K needs to be placed somewhere, Atmel and Microchip came to different conclusions where this extra bit should be placed, so they are not compatible.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • DavidMDavidM Posts: 626
    edited 2007-03-14 22:55
    Thanks everyone for their help.

    dave M
  • OwenOwen Posts: 100
    edited 2007-03-14 23:08
    so does this meen that I can only use the atmel chips with the propellar unless I use more than one chip? atmel to boot the program into ram, microchip on seperate i/o pins for additional memory?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-14 23:14
    Owen,
    Why would you think that?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-03-14 23:55
    No all it means is that code for an Atmel 128KByte EEPROM upper 64KB bank wont work for a Microchip 128KByte EEPROM upper 64KB bank and vice versa. Since the Propeller never loads anything above 32K upon startup, it is irrelevant which chip is used.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 3/14/2007 11:59:42 PM GMT
  • paulmacpaulmac Posts: 51
    edited 2007-03-15 12:55
    IWriteCode said...
    It's 256 Kbits, which is 32 KBytes.

    So does this mean that there are 32,000 memory locations/addresses, each 8 bits wide, within a 24LC256 EEPROM?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I stand on the shoulders of giants
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-15 13:50
    paulmac,
    Yes. Most 8-pin EEPROMs get their part numbers from the number of bits in the EEPROM even though they're organized as bytes so a 24LC256 as you've indicated is 32K x 8, similarly a 24LC512 is 64K x 8, and a 24LC1024 is 128K x 8.
  • mahjonggmahjongg Posts: 141
    edited 2007-03-15 15:38
    davidM

    For a simple solution, the simplest solution might be to add -another- EEPROM on a seperate pair of I/O pins, so your storage EEPROM has nothing to do with your boot EEPROM.

    Another solution would be to use the same I2C interface, but use a second EEPROM with a different adress. For example, on a AT24C1024 pin 2 controls which "address" the memory chip is placed. For smaller EEPROM,s pins 1,2 and 3 are used.

    I am not sure, but I think the simple boot I2C driver must be modified to drive more than one EEPROM, I think I read somewhere that it now "hard drives" the data and clock lines, instead of leaving them "open collector", so if your design does not use a pullup resistor on both the data line and clock lines, maybe you need to add them.

    Perhaps Parallax, or somebody else, can write a comprehensive set of library routines to write/read from the memory above the 32K border, and place them in the library (and/or a "sticky thread"). It seems a lot of people are trying to use the EEPROM to add more than the available 32K of code, or to store data permanently.
    It would be a valuable addition to the library, so that nobady has to "re-invent the wheel" each time when trying to do more with the EEPROM than just booting off it.

    Mahjongg
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-15 15:53
    There are already two contributed sets of library routines in the Propeller Object Exchange that have "methods" for reading and writing EEPROM given an EEPROM address, a Spin (Hub RAM) data address, and byte count. Both sets of routines will work with or without a pullup on the clock line and will work with an EEPROM on any pair of I/O pins.

    As far as these routines are concerned, it doesn't matter whether you have an EEPROM larger than 32K x 8 or two or more EEPROMs on the same set of pins or on different sets of I/O pins. You don't need to have any EEPROM other than the boot EEPROM (see Chip's comment earlier).
Sign In or Register to comment.