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


Results 1 to 37 of 37

Threaded View

  1. #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 19: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