Electronic – EEPROM returns 0 while trying to read anything

ceepromspitexas instruments

I'm using a CC2652r to try to read and write to an MX25R8035F EEPROM using SPI.

I'm using the build in SPI driver to try and communicate with the EEPROM but while the drivers says it succeeded the transfer of data, the data I get back seems to be 0 at all times.

For example if I try to use the REMS (read electronic
manufacturer & device ID) to get the manufacturer & device ID I send 4 bytes containing 0x90, 0xFF, 0xFF, 0x00. But instead of getting 0xC2, 0x14. I'm getting 0x00 and 0x00.

I initialize my SPI with:

    /* Open SPI as master (default) */
    SPI_Params_init(&spiParams);
    spiParams.dataSize = 8;
    spiParams.bitRate = SPI_BIT_RATE; //(4000000)
    spiParams.frameFormat = SPI_POL0_PHA0;
    masterSpi = SPI_open(MX25_EEPROM_SPI, &spiParams);
    if (masterSpi == NULL) {
        System_abort("Error initializing SPI\n");
    }

Then in a Task I try to get the electronic manufacturer & device ID with:

//BLS_CODE_MDID = 0x90
    uint8_t wbuf[] = { BLS_CODE_MDID, 0xFF, 0xFF, 0x00 };
    SPI_Transaction transaction;

    // Configure the transaction
    transaction.count = sizeof(wbuf);
    transaction.txBuf = wbuf;
    transaction.rxBuf = NULL;
    extFlashSelect();
    uint8_t ret = (uint8_t) (!SPI_transfer(masterSpi, &transaction));

    // Configure the transaction
    transaction.count = sizeof(infoBuf);
    transaction.txBuf = NULL;
    transaction.rxBuf = infoBuf;

    ret = (uint8_t) (!SPI_transfer(masterSpi, &transaction));
    extFlashDeselect();

Where extFlashSelect put the slave select pin low and extFlashDeselect put it to high.

I also tried setting the rxBuf and the txBuf in the same transaction but got the same result.

I hope someone is able to help me with this.

EDIT:
I tried specifying the frame format in the parameters passed to SPI_open.
According to the documentation of MX25R8035F, CPOL 0, CPHA 0 and CPOL 1, CPHA 1 together should be supported but the result is still the same.

Best Answer

So I tried some more stuff. Eventually I tried to read the REMS using an arduino that worked after sending a dummy byte while trying to retrieve data.

I now tried the same with the TI board and it returned data.

Updated function for retrieving the REMS is now:

    //BLS_CODE_MDID = 0x90
    uint8_t wbuf[] = { BLS_CODE_MDID, 0xFF, 0xFF, 0x00 };

    SPI_Transaction transaction;
    uint8_t dummy[] = { 0 };
    uint8_t infoBuf[2];

    // Configure the transaction
    transaction.count = sizeof(wbuf);
    transaction.txBuf = wbuf;
    transaction.rxBuf = NULL;

    extFlashSelect();

    if (!SPI_transfer(masterSpi, &transaction)) {
        return 1;
    }

    // Configure the transaction
    transaction.count = sizeof(infoBuf);
    transaction.txBuf = dummy;
    transaction.rxBuf = infoBuf;

    uint8_t ret = (uint8_t) (!SPI_transfer(masterSpi, &transaction));
    extFlashDeselect();