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
  • I am not sure how you are going to maintain code that you didn't write or don't understand. The driver starts with the serial command and address then switches to the user address by a counter in the interrupt routine.

    typedef enum {
      WRSR  = 0x0100,  /* Write Status Register             */
      WRITE = 0x0200,  /* Write Data to Memory Array  */
      READ  = 0x0300,  /* Read Data from Memory Array */
      WRDI  = 0x0400,  /* Reset Write Enable Latch  */
      RDSR  = 0x0500,  /* Read Status Register              */
      WREN  = 0x0600,  /* Set Write Enable Latch      */
    } EepromCommandType;
    
    _inline void EepromStartTx(void) {
      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 */
    }
    

Reply
  • I am not sure how you are going to maintain code that you didn't write or don't understand. The driver starts with the serial command and address then switches to the user address by a counter in the interrupt routine.

    typedef enum {
      WRSR  = 0x0100,  /* Write Status Register             */
      WRITE = 0x0200,  /* Write Data to Memory Array  */
      READ  = 0x0300,  /* Read Data from Memory Array */
      WRDI  = 0x0400,  /* Reset Write Enable Latch  */
      RDSR  = 0x0500,  /* Read Status Register              */
      WREN  = 0x0600,  /* Set Write Enable Latch      */
    } EepromCommandType;
    
    _inline void EepromStartTx(void) {
      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 */
    }
    

Children