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
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41

    Default

    Well I just ordered the 24AA1025 (1024K I2C™ CMOS Serial EEPROM) and that way I will be able to use PBP's I2C capability.

    However, I would still like to know how to use the 25AA1024 as I have a few lying around now that are just gunna go to waste otherwise.

    Thanks

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

    Default

    SHIFTIN/SHIFTOUT should work for the 25aa1024. You will need to look at the data sheet for the correct modes and all of that stuff.

    This page has a few example about SHIFTIN/OUT and SPI.
    http://www.melabs.com/resources/samples.htm
    Last edited by mackrackit; - 29th March 2010 at 04:26.
    Dave
    Always wear safety glasses while programming.

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

    Default

    SHIFTIN/SHIFTOUT should work for the 25aa1024. You will need to look at the data sheet for the correct modes and all of that stuff.

    This page has a few example about SHIFTIN/OUT and SPI.
    http://www.melabs.com/resources/samples.htm
    Thanks for the heads up! I don't know how I missed that sample ,the "spix.bas" to begin with. I guess I just had to scroll down a little more :/

    Seeing how I dont have the time to find this out for a few days... what chip should I expect to be quicker the I2C or the SPI? Both will be running off of a 4 MHz clock.

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

    Default

    I do not know which is faster, never did a side by side or studied the specs for that.
    Let us know what you find. It will be interesting to see.
    Dave
    Always wear safety glasses while programming.

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

    Default I can't WRITE to the I2C What am I doing wrong?

    I made my address a WORD because the 24AA1025 (1024K I2C™ CMOS Serial EEPROM) has a 2 byte address. So in theory this should work but as you can see the output is reading "0" in every address when it should be reading "5"

    Does my code look right?

    I am unsure of the PAUSE 10ms as I can't find any specs in the data sheet for the amount of time needed after each WRITE cycle. I tried commenting out the delay but still the same results. One would think if the delay was wrong I would still get a "5" in Addr0 at the very least.

    Here is the schematic I used to wire up the 24AA1025 to my 16F88:
    http://melabs.com/resources/pbpmanual/5_30-5_31.htm

    Here is the code:
    Code:
    SO      con     0                       ' Define serial output pin
    T2400   con     0                       ' Set serial mode
    DPIN    var     PORTA.0                 ' I2C data pin
    CPIN    var     PORTA.1                 ' I2C clock pin
    B0      var     WORD                    ' Address
    B1      var     byte                    ' Data from first address read
    B2      var     byte                    ' Data from second address read
    B3      var     byte                    ' Second Address
    
       For B0 = 0 To 15                                    ' Loop 16 times
          I2CWRITE DPIN,CPIN,$A0,B0,[5]                    ' Write a "5" to each location
          Pause 10                                         ' Delay 10ms after each write
       Next B0
    
    loop:  
     
       For B0 = 0 To 15 step 2                                          ' Loop 8 times
       high 3                                                           ' LED on to signify a Read in progress
          I2CREAD DPIN,CPIN,$A0,B0,[B1,B2]                              ' Read 2 locations in a row
          B3 = B0 + 1                                                   ' Create second address for print
          Serout SO,T2400,["Addr",#B0,":",#B1,13,10,"Addr",#B3,":",#B2,13,10]  ' Print 2 locations
          B3 = 0                                                        ' Zero out B3 Variable
       low 3                                                            ' LED off to signify no read in progress
       Next B0
    
       Serout SO,T2400,[13,10]             ' Print linefeed
     
       Goto loop
    And here is what I get on Hyperterm:
    Code:
    Addr0:0       
    Addr1:0       
    Addr2:0       
    Addr3:0       
    Addr4:0       
    Addr5:0       
    Addr6:0       
    Addr7:0       
    Addr8:0       
    Addr9:0       
    Addr10:0        
    Addr11:0        
    Addr12:0        
    Addr13:0        
    Addr14:0        
    Addr15:0
    Last edited by wolwil; - 3rd April 2010 at 18:30. Reason: added link to schematic

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

    Angry Going Nuts!!!

    I simplified everything and have tried everything (even tried swapping out the chip) but I cant get this EEPROM to write anything to it. Here is the new simplified code:

    Code:
    SO      con     0                           ' Define serial output pin
    T2400   con     0                           ' Define serial mode
    cont    CON     %10100000                   ' Define Control byte
    addr    CON     %0000000000000111           ' 2 Byte Address of 7
    B1      VAR     BYTE                        ' Var for data being read
    
    I2CWRITE PORTA.0,PORTA.1,cont,addr,[1]      ' Send the byte 1 to address 7
    
    PAUSE 10                                    ' Wait 10ms for write to complete
    
    I2CREAD PORTA.0,PORTA.1,cont,addr,[B1]      ' Read address 7 into B1
    
    Serout SO,T2400,["Addr",#addr,":",#B1,13,10] ' Print B1's Value in DEC
    Correct me if I'm wrong but the above code should work but it still just reads "0" in hyperterm like this: "Addr7:0"

    I am reading 4.97V from pins 4-8 and I get 4.82V from 4-5 and 4-6 on the 24FC1025 EEPROM so my voltage is within specs. I have checked all continuity on the circuit and they all tone out.

    I don't know what else to do. Please help.

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

    Angry I found 1 problem with my circuit.

    Pin A2 needed to be tied to VCC not VSS in order for the chip to be enabled. This however has not fixed my problem I am still getting nothing written to it.

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