This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Programming to external EEPROM

Hello. I need some help.
I'm trying to write, read and erase an external EEPROM (25AA040 MICROCHIP) via SPI from XC164CS board, for example, one byte at 0x00 adress of the eeprom, but i don't know how to do it.
Into the datasheet, I can see some instructions but i don't know what to do with them:
img28.imagevenue.com/img.php
Could anyone help me?
Thank you very much. :)

Parents Reply Children
  • In opinion of Chris, only the enum EepromCommandType must be changed (I have already changed it) and modify the start address of pointer, but i don't know how to do it. This is the modified version by me.

    _inline void EepromStartTx(U16  MY_ADRESS) {
      CS_EEPROM      = low;
      eeprom.bytesTx = 1;                        /* decrement the transmit count by one */
      eeprom.bytesRx = 0;
      eeprom.txptr   = (S8 *)(&eeprom)+MY_ADRESS;  /* reset pointer to first element */
      SSC0_TB         = *eeprom.txptr++;     /* write the first byte to the SSC0 tx buffer */
      }
    
    

  • Hello,
    Tamir, Chris, my nigthmare has ended. I have tested the last configuration of Chris, and the program works perfectly. I read /write the bytes in the wished address. It isn't necessary to add a new parameter in the
    EepromStartTx function. Only the pointer has to be increased by 1.

    _inline void EepromStartTx() {
      CS_EEPROM      = low;
      eeprom.bytesTx = 1;                        /* decrement the transmit count by one */
      eeprom.bytesRx = 0;
      eeprom.txptr   = (S8 *)(&eeprom) + 1;  /* reset pointer to first element */
      SSC0_TB         = *eeprom.txptr++;     /* write the first byte to the SSC0 tx buffer */
      }
    
    


    Thanks very much for your help.