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 How to read & write to a 25aa1024 (1 Mbit SPI Bus Serial EEPROM) via 16F88

    I'm a newb to all of this and I bought PBP so I wouldn't have to learn assembly but I may have been wrong.

    From what I can gather bit banging in PBP may be the only way to do it but I was hoping that maybe there may be another way.

    For example:
    Would it be possible to bit bang just the initial WRITE ENABLE SEQUENCE (WREN) of it then switch to I2C for the address/data portion and finally bit bang the WRITE DISABLE SEQUENCE (WRDI)

    or

    If PBP can compile assembly along side of PB and someone would be kind enough to supply me with the some example assembly and coach me through it so I understand it, that would be great too?

    Thanks

  2. #2
    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

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    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

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