SPI receive

I/ trying to read the ID of a Fijitsu FRAM type MB85RS4MT using the Nordic device nRF5340. I can properly initialize the SPI and transmit the RDID =0x9F command. The FRAM returns, what I think is the proper ID, but it won't show up in software. I'm using the synchronous spi_transceive routine. I Initialize the ID buffer prior use with all 0xFF. The data is overwritten with all zeros ?. This is how the DTC and code looks like. I'm really stuck, can it have something to do with double use of GPIOs ???? within the Device Tree visual editor it appears that NFC is disabled (also using pin P0.03). Could it be that the NFC part it somehow blocking proper use of the pins for SPI. (How can I check?) 

The code looks as follows:

______________________________________________________________________________________________________________________________

static int spi_transfer(const struct device *spi_dev, struct spi_config *spi_cfg, uint8_t *tx_buf, size_t tx_len, uint8_t *rx_buf, size_t rx_len)
{
    /// READ github.com/.../65512

    struct spi_buf tx_buffer[1] = {
        {
            .buf = tx_buf,
            .len = tx_len,
        }
    };

    struct spi_buf rx_buffer[2] = {
        {
            .buf = tx_buf,
            .len = tx_len,
        },
        {
            .buf = rx_buf,
            .len = rx_len,
        }
    };

    struct spi_buf_set tx_set = {
        .buffers = tx_buffer,
        .count   = 1,
    };

    struct spi_buf_set rx_set = {
        .buffers = rx_buffer,
        .count   = 2,
    };

#if defined(CONFIG_SPI_ASYNC)
    return spi_transceive_cb(spi_dev, spi_cfg, &tx_set, &rx_set, spi_rdy, NULL);
#else
    /* Synchronous SPI transfer */

    return spi_transceive(spi_dev, spi_cfg, &tx_set, &rx_set);
#endif
}

static int read_id(const struct device *spi_dev, struct spi_config *spi_cfg)
{
    uint8_t id[4]  = { 0xFF };
    uint8_t cmd[1] = { MB85RS4MT_RDID };

    if (0 != spi_transfer(spi_dev, spi_cfg, cmd, sizeof(cmd), id, sizeof(id)))
    {
        return -EIO;
    }

    if (id[0] != 0x04)
    {
        return -EIO;
    }

    if (id[1] != 0x7f)
    {
        return -EIO;
    }

    if (id[2] != 0x49)
    {
        return -EIO;
    }

    if (id[3] != 0x0B)
    {
        return -EIO;
    }

    return 0;
}
________________________________________________________________________________________________________________

So id[4]  is overwritten with all zeros????

I really don't understand what is going on. Note that all connections between the FRAM and nRF are straight forward. Checked the print layout and stuff. 

Parents Reply Children
No Data
Related