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


Results 1 to 37 of 37

Threaded View

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

    Default I made a break through I just don't know what it means :D

    I changed the Control Byte for the read and the write from this:
    Code:
    contR    CON     %10100001                  
    contW    CON     %10100000
    to this:
    Code:
    contR    CON     %10100011                  
    contW    CON     %10100010
    Thinking that because A2 is held high for it to operate then the control bit for A2 should also be a 1... here is the new code:
    Code:
    DEFINE I2C_SLOW 1
    SO      con     0                           ' Define serial output pin
    T2400   con     0                           ' Define serial mode
    contR    CON     %10100011                   ' Define Control byte
    contW    CON     %10100010                   ' Define Control byte
    addr    CON     %0000000000000111           ' 2 Byte Address of 7
    addr2   CON     %0000000000001000           ' 2 Byte Address of 8
    D1      CON     %00000111
    B0      VAR     BYTE                        ' Var for data being read
    B1      VAR     BYTE                        ' Var for data being read
    
    B0 = 0
    B1 = 0
    I2CWRITE PORTB.1,PORTB.4,contW,addr,[D1]      ' Send the byte 1 to address 7
    
    PAUSE 10                                    ' Wait 10ms for write to complete
    
    I2CREAD PORTB.1,PORTB.4,contR,addr,[B1]      ' Read address 7 into B1
    I2CREAD PORTB.1,PORTB.4,contR,addr2,[B0]      ' Read address 8 into B0
    
    Serout SO,T2400,["Addr",#addr,":",#B1," and then Addr",#addr2,":",#B0,13,10] ' Print B1's Value in DEC
    this is the output from hyperterm:
    Code:
    Addr7:2 and then 2
    Like I said I don't know what it means but it sure is different then what I was getting.

    Any thoughts as to why it now is reading a "2" and not 255 or 0??? Its almost like it read the last 2 bits of the write control byte as if the write command wrote the last 2 bits of the control byte to the EEPROM.


    UPDATE:
    I just switched the control byte to be:
    Code:
    contR    CON     %10100001                  
    contW    CON     %10100010
    and got this as an output (Note the "6" in Address 8 to begin and then it get over written to "255" the next go around):
    Code:
    Addr7:2 and then Addr8:6
    Addr7:2 and then Addr8:255
    Addr7:2 and then Addr8:255
    Addr7:2 and then Addr8:255
    Addr7:2 and then Addr8:255
    also I know I'm writing to it because in the example output above I read address 6 with it too (not shown in the code but I added it after posting) and I was reading "255" every time. So this tells me that I am writing a "6" to address 8 but then on the second loop it gets over written/erased to "255" but the "2" in address 7 remains constant and in memory. Now keep in mind that no where in my code do I try to write to address 8 it just happens, more than likely from an over flow from the write to address 7. So basically the byte I am trying to write to 7 gets split into a "2" in address 7 and a "6" in address 8 then address 8 gets overwritten on the 2nd loop to a "255".

    and when I do the control byte like this:
    Code:
    contR    CON     %10100011                  
    contW    CON     %10100000
    I get this (the same as having both A2 bits set to 1):
    Code:
    Addr7:2 and then Addr8:2
    Addr7:2 and then Addr8:2
    Addr7:2 and then Addr8:2
    Last edited by wolwil; - 17th April 2010 at 05:37.

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