Shop OBEX P1 Docs P2 Docs Learn Events
Saving to EEPROM — Parallax Forums

Saving to EEPROM

JomsJoms Posts: 279
edited 2010-01-29 04:48 in Propeller 1
I was using the search function but having problems·finding good examples.· Can anyone point me towards a document that might explain this function better.
·
I am trying to save 4 different strings to the EEPROM where they can be accessed after a power failure.· I know I can't write them very often, as they will only probably change once a year or so.
·
I am using a I2C object already to read from a real time clock IC.· I have been looking at an example that Terry from Hitt Consulting put together, but having problems understanding exactly what is going on.
·
If anyone knows of a good tutorial, I would greatly appreciate it.· Thanks!

Comments

  • mctriviamctrivia Posts: 3,772
    edited 2010-01-29 03:57
    Search for an object called

    Id

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    24 bit LCD Breakout Board now in. $24.99 has backlight driver and touch sensitive decoder.

    If you have not already. Add yourself to the prophead map
  • JomsJoms Posts: 279
    edited 2010-01-29 04:48
    OK, This is mainly based of Terry's code from Hitt Consulting... I am trying to save a string called tempStr and recall it and store it as a string called tempStr2. Am I anywhere close to where I should be with the code, or am I missing something major?

    PUB SaveToEEPROM | pos, addr, temp
    
      pos:=2        '<-change 1/2/3/4 for different Memory Positions
     
      addr:=32768 + (pos-1) * 12288    
      ' Start the I2C (EEPROM) Object 
      I2C.Init(28, 29, $A0) ' Use Propeller Demo Board EEPROM
      I2C.i2cStart
      IF addr < 65536
        I2C.i2cWrite($A0, 8)
      ELSE
        I2C.i2cWrite($A2, 8)  
      I2C.i2cWrite((addr / 256), 8) 
      I2C.i2cWrite((addr // 256), 8)
      REPEAT temp FROM 0 TO MaxChar 
        I2C.i2cWrite(tempStr[noparse][[/noparse]temp], 8)
        tempStr[noparse][[/noparse]temp]:=tempStr[noparse][[/noparse]temp] ^ 255
        IF (addr & $FF) == $FF
          I2C.i2cStop
          WAITCNT(400000 + cnt) ' 5mSec
          I2C.i2cStart
          IF (addr+1) < 65536
            I2C.i2cWrite($A0, 8)
          ELSE
            I2C.i2cWrite($A2, 8)  
          I2C.i2cWrite(((addr+1) / 256), 8)
          I2C.i2cWrite(((addr+1) // 256), 8)
        addr+=1
      I2C.i2cStop
      WAITCNT(400000 + cnt) ' 5mSec
      REPEAT temp FROM 0 TO MaxChar
        tempStr[noparse][[/noparse]temp]:=tempStr[noparse][[/noparse]temp] ^ 255
    
      
    PUB LoadFromEEPROM | pos, addr, temp
    
      pos:=2       '<-change 1/2/3/4 for different Memory Positions
      
      addr:=32768 + (pos-1) * 12288    
      ' Start the I2C (EEPROM) Object 
      I2C.Init(28, 29, $A0) ' Use Propeller Demo Board EEPROM
      I2C.i2cStart
      IF addr < 65536
        I2C.i2cWrite($A0, 8)
      ELSE
        I2C.i2cWrite($A2, 8)  
      I2C.i2cWrite(addr / 256, 8)
      I2C.i2cWrite(addr // 256, 8)
      I2C.i2cStart
      I2C.i2cWrite($A1, 8)
      REPEAT temp FROM 0 TO MaxChar
        tempStr2[noparse][[/noparse]temp]:=I2C.i2cRead(0, 8)
      I2C.i2cStop
    
    
Sign In or Register to comment.