How to read & write to a 25aa1024 (1 Mbit SPI Bus Serial EEPROM) via 16F88


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    How do you have pins A0 and A1 connected?

    I have not had a chance to work on this today yet so I do not have any new news.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41

    Default

    Quote Originally Posted by mackrackit View Post
    How do you have pins A0 and A1 connected?

    I have not had a chance to work on this today yet so I do not have any new news.

    Tied to ground.

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default This one is for Dave...

    mackrackit, You can't use Shiftout and Shiftin for an I2C bus driven part. That is why you had no luck using it with a 24FC1025... It requires the pullup resistor for communicating the ACK signal back to the processor. Shiftout keeps the pin in an active state wghich ever it is... I recently posted code for talking to 24LC1025's here on the forum... Why not just use it for a starting point... I don't remember which thread it was in reply to but I believe it had to do with I2C....

    Dave Purola,
    N8NTA

  4. #4
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41

    Default

    Dave,

    I've searched through all the posts on the 24LC1025 and didn't find any code you posted but I found code that is basically the same as what I have tried already. If you can find the thread you were thinking of that would be great.

    The only thing I have not tried is changing is my pullups from 4.7k to 2k and trying to write to it 1 page at a time but if I cant byte-write to begin with I'm sure the page write will not work either. I will try changing the Pullups tonight and see what happens.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    I got the idea for shifting here.
    http://www.rentron.com/PicBasic/i2c_communication.htm

    Reading back over my code and data sheet I see some things are backwards. Maybe ...

    Never did find that code posting. Found lots of others for different parts.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41

    Default Changed the Pullups to 2.2K and still no change

    Everything is the same as before with the new pullup values of 2.2K...back to the drawing board

    I am going to be out of town for the next week so I wont be able to test anything new but I will be on here checking if any new ideas/breakthroughs come up.
    Last edited by wolwil; - 18th April 2010 at 02:24.

  7. #7
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default

    wolwil, Here it is again incase you didn't find it. Maxpages is set for 1023 x the number of 24LC1025's you have connected. The routine saves the last storage pointer in the last 2 locations of the last 24LC1025. Block is incremented once for each page. Before you start a clean write you would set block to 0 which is the first page. When you want to read back the data then you would call READ_WRITE_BLK1025 and block would have the last address written..

    This routine is rock solid and I use it for accessing 4 x 24LC1025's for a total of over 4 gigabits of memoy to record Azmnuth,Elevation,East/West/Up/Down Sensor data and control flag information for about 2 months at 1 minute intervals... I hope this helps...

    Code:
     
    CNTRL_BYTE    CON    $A0        'CONTROL BYTE FOR 24LC1025 I2C EEPROM MEMORY (A0/A1 USED FOR CHIP SELECT)
    MAX_PAGES    CON    4095    'MAXIMUM MEMORY STORAGE PAGES,(32 BYTES/MINUTE x 4 MINUTES x PAGES = TOTAL MINUTES)
     
    '*********************************************************************
    RW_EEPROM1025:        'READ FROM or WRITE TO SERIAL EEPROM
    '*********************************************************************
        IF READ_WRITE = 1 THEN    'WRITE 128 BYTE BLOCK TO EEPROM
            IF BLOCK <> 0 THEN    'IF STARTING NEW PASS DON'T READ OLD LOCATION
                READ_WRITE = 0    'SET FOR BLOCK READ
                GOSUB READ_WRITE_BLK1025    'READ FROM SERIAL EEPROM NEXT AVAILABLE STORAGE BLOCK
                READ_WRITE = 1    'SET FOR BLOCK WRITE
            ENDIF
            DEVICE = BLOCK / 512    'SELECT WHICH PHYSICAL ADDRESS BOUNDRY & EEPROM
            ADDRESS = BLOCK << 7    'CALCULATE 12C ADDRESS TO STORE DATA TO
            CNTROL_BYTE = CNTRL_BYTE    'COPY CONTROL BYTE
            CNTROL_BYTE.1 = DEVICE.1    'SET LSB OF HARDWARE ADDRESS
            CNTROL_BYTE.2 = DEVICE.2    'SET MSB OF HARDWARE ADDRESS
            CNTROL_BYTE.3 = DEVICE.0    'SET 64K BLOCK BIT
            INTCON.7 = 0    'CLEAR GLOBAL INTERRUPT
            I2CWRITE SDA,SCL,CNTROL_BYTE,ADDRESS,[STR STOR_DATA\128]    'SAVE DATA TO 12C
            WRITEOCCURED = 1
            INTCON.7 = 1    'SET GLOBAL INTERRUPT
            PAUSE 6        'ALLOW TIME FOR I2C WRITE ~5Ms.
            BLOCK = BLOCK + 1    'INCREMENT FOR NEXT AVAILABLE BLOCK TO WRITE
            BLOCK = BLOCK MIN MAX_PAGES    'LIMIT TO n BLOCKS OF 128 BYTES
            GOSUB READ_WRITE_BLK1025    'WRITE TO or READ FROM SERIAL EEPROM LAST STORAGE BLOCK
        ELSE
            DEVICE = BLOCK / 512    'SELECT WHICH PHYSICAL ADDRESS BOUNDRY & EEPROM
            ADDRESS = BLOCK << 7    'CALCULATE 12C ADDRESS TO STORE DATA TO
            CNTROL_BYTE = CNTRL_BYTE    'COPY CONTROL BYTE
            CNTROL_BYTE.1 = DEVICE.1    'SET LSB OF HARDWARE ADDRESS
            CNTROL_BYTE.2 = DEVICE.2    'SET MSB OF HARDWARE ADDRESS
            CNTROL_BYTE.3 = DEVICE.0    'SET 64K BLOCK BIT
            INTCON.7 = 0    'CLEAR GLOBAL INTERRUPT
            I2CREAD SDA,SCL,CNTROL_BYTE,ADDRESS,[STR READ_DATA\128]    'LOAD IN ENTIRE BLOCK
            WRITEOCCURED = 1
            INTCON.7 = 1    'SET GLOBAL INTERRUPT
        ENDIF
        RETURN
     
    '*********************************************************************
    READ_WRITE_BLK1025:    'WRITE TO or READ FROM SERIAL EEPROM NEXT AVAILABLE STORAGE BLOCK
    '*********************************************************************
        ADDRESS = 65534        'POINT TO LAST STORED DATA(WORD) ADDRESS
        DEVICE = MAX_PAGES / 512    'SELECT WHICH PHYSICAL ADDRESS BOUNDRY & EEPROM
        CNTROL_BYTE = CNTRL_BYTE    'COPY CONTROL BYTE
        CNTROL_BYTE.1 = DEVICE.1    'SET LSB OF HARDWARE ADDRESS
        CNTROL_BYTE.2 = DEVICE.2    'SET MSB OF HARDWARE ADDRESS
        CNTROL_BYTE.3 = DEVICE.0    'SET 64K BLOCK BIT
        IF READ_WRITE = 1 THEN
            INTCON.7 = 0    'CLEAR GLOBAL INTERRUPT
            I2CWRITE SDA,SCL,CNTROL_BYTE,ADDRESS,[BLOCK.LOWBYTE,BLOCK.HIGHBYTE]    'WRITE DATA POINTER TO 12C    
            WRITEOCCURED = 1
            INTCON.7 = 1    'SET GLOBAL INTERRUPT
            PAUSE 6        'ALLOW TIME FOR I2C WRITE ~5Ms.
        ELSE
            INTCON.7 = 0    'CLEAR GLOBAL INTERRUPT
            I2CREAD SDA,SCL,CNTROL_BYTE,ADDRESS,[BLOCK.LOWBYTE,BLOCK.HIGHBYTE]    'READ DATA POINTER FROM 12C    
            WRITEOCCURED = 1
            INTCON.7 = 1    'SET GLOBAL INTERRUPT
        ENDIF
        RETURN
    Dave Purola,
    N8NTA
    Last edited by ScaleRobotics; - 14th June 2010 at 02:24. Reason: Added code tags

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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