Shop OBEX P1 Docs P2 Docs Learn Events
storing a few values into upper half of 24LC512 (64kB) EEPROM — Parallax Forums

storing a few values into upper half of 24LC512 (64kB) EEPROM

StefanL38StefanL38 Posts: 2,292
edited 2014-07-08 13:51 in Propeller 1
Hi,

after a long time I'm working on a project for my father. building a programmable Timer for a 230V-Pump.

Menus on a serial LCD are up and running. Now I want to store the times when to switch on / off the pump
in the upper half of a 24LC512 (64kB) EEPROM.

I tried the HITT_Boot_EEPROM_010.spin-object. And Kyes I2C-engine No luck so far
It's a DIY-Propellerboard with EEPROM wired as in the manual
all three adress-pins connected to ground PIN29 (SDA) with a pullup-resistor

Which I2C-driver do you recommend?
It would be very helpful to have demo-code that shows how to use the methods and also has documentation what the
result should be

Kyes driver has a small circuit showing the SCL-line should have a pullup-resistor too?

How the heck can the propeller-tool work with the EEPROM without a SCL-Pullup but not the drivers?
or does this not matter???

best regards
Stefan

Comments

  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-07-08 10:36
    The propeller tool when it loads the main eeprom actively drives scl both to the high level and to the low level (pin 28), so it does not need a pullup. It is a one-direction communication. Some of the early project boards from Parallax (demo, proto) did not in fact include the pullup resistor on pin 28, and as a consequence drivers that expect a pullup resistor do not work with those particular boards. More recent Parallax boards as well as third party boards do include the pullup resistor. That is more in line with the i2c specification, as there are relatively rare cases where both scl and sda need to be bidirectional. Some of the existing i2c drivers do drive scl, some do not. If you included the pullup resistor in your design either type should work. I don't know why you are having trouble with the high memory. The driver does have to support at least 16 bit addresses. Post a snippet of your code.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-07-08 10:45
    How much data are you storing? If you try to write across EEPROM page boundaries in a single write, you'll likely have trouble. An easy way around this (though causing more wear on the EEPROM) is to write a single long a time. This is a lazy way to make sure you don't write across boundaries.

    There's a EEPROM datalogging section in the Propeller sticky about the PEK.

    The only boards I'm aware of which don't include pull-ups on both data and clock are the Demo Board, The PPDB and jazzed's TetraProp board (though it's not too hard to add a pull-up on the clock on TetraProp).

    Some I2C devices can do tricks like clock stretching (or so I've read) which requires a pull-up on the clock line as well as the data.
  • T ChapT Chap Posts: 4,223
    edited 2014-07-08 11:00
    The way I use the upper EEPROM is to do the following:

    Give the EEPROM address a name in CON. Start at $8000, increase the address number based on the the number of bytes that may be written to that address.
    Make a method that is called GETPREFS so that on boot, it reads any values you want loaded right away.
    Make a method that writes a value to the EEPROM a la carte whenever you want to update the stored values
    Make a method that writes ALL values to the EEPROM called SETDEFAULTS this is one shot reset to default values



    Examples
    CON
        epValue1 = $8000     'the eeprom address for value 1 to live   
        epValue2 = $8000 + 4  'assuming previous values was long
        epValue3 = $8000 + 8  'assuming previous values was long
    
    
        EEPROM1         = %1010_000_0 
    
    OBJ
        i2c1         : "CLEAN_minimali2cdriversmall"      'very basic driver
    
    VAR
        LONG  Value1
    
    
    PUB WriteValue1
        WritePage(eeprom1, epValue1, @Value1, 4)  ' length of this value is 4 bytes long   set this based on the length needed
    
    PUB ReadValue1
        ReadPage(eeprom1, epValue1 , @Value1, 4)  ' length of this value is 4 bytes long
        
    
    PUB WritePage(devid, address, pointer, count)
        i2c1.i2cWritepage(28, devid, address, pointer, count)
        waitcnt(clkfreq/200 + cnt)
        i2c1.i2cstop(28)
    
    PUB ReadPage(devid, address, pointer, count)           'boot eeprom $A0
        i2c1.i2cstart(28)
        i2c1.i2cReadPage(28, devid, address, pointer, count)    '$7000test
        i2c1.i2cstop(28)
        return  pointer
    
    
    PUB SetDefaultPrefs  | j      '''static presets,  not eeprom
        'storage starts at $8000
         Value1~
         WriteValue1
    
    PUB GetPrefs
        'storage starts at $8000
        ReadPage(EEPROM1, epValue1, @Value1, 1)
    
    
    


    To test, set a value to Value1, write it to eeprom, then read it back from eeprom.
  • RaymanRayman Posts: 14,658
    edited 2014-07-08 12:27
    Here's what I did for storing a bitmap in upper EEPROM:
    OBJ
       eeprom:  "Propeller EEPROM"
       
    
    DAT 'Test Windows bitmaps to show
    WindowsBitmap byte
         file "HappyNewYear_4bit.bmp"
    
    PUB Main
      'Copy bitmap to upper eeprom
      eeprom.FromRam(@WindowsBitmap,@WindowsBitmap+6000,33000) 'Merry Xmas 
      'eeprom.ToRam(@WindowsBitmap,@WindowsBitmap+6000,33000) 
    

    I trimmed the code and changed some things to make it look more readable...

    Here FromRam copies 6000 bytes to eeprom starting at address 33000.
    ToRam copies it back...
  • StefanL38StefanL38 Posts: 2,292
    edited 2014-07-08 13:51
    Hi all,
    thank you very much for your answers and code samples.

    It turned out to be a variant of murphy's law: ask for software and find the hardware-bug.
    It was indeed the missing pullup-resistor on SCL. After adding the PullUp everything works fine now.

    best regards
    Stefan
Sign In or Register to comment.