This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840 Dongle + s140 softdevice + SPI

I am working on a device driver for the W25Q128JV flash device. This is the first SPI device I've used with the nRF52840. I had some observations and questions about SPI programming on this mcu.

int w25q128_flash__read_device_id(w25q128_flash f, uint8_t *device_id)
{
    uint8_t buf[5] = {0};

    buf[0] = 0xAB;
    ret_code_t ret = nrf_drv_spi_transfer(f->spi, buf, 4, buf, 5);

    *device_id = buf[4];

    return ret;
}
This is functionally the same as this:
int w25q128_flash__read_device_id(w25q128_flash f, uint8_t *device_id)
{
    uint8_t wr_buf[4] = {0};
    uint8_t rd_buf[5] = {0};

    wr_buf[0] = 0xAB;
    ret_code_t ret = nrf_drv_spi_transfer(f->spi, wr_buf, 4, rd_buf, 5);

    *device_id = rd_buf[4];

    return ret;
}
The second example is more like the spi example provided in the sdk. In the command, the 0xAB is an instruction, but is then followed by 3 dummy bytes. The next byte is then the id, which reads as 0x17. 
 
It seems like moving forward, I could use the single buffer and then offset the data like in the first example. This seems cleaner than the second example. What is typical on the nrf52840? Is the data read offset the way it should work, or is there a possible setup issue somewhere? I've implemented several functions using this offset approach, and it works fine, but wanted some opinions of other folks who have used SPI on the nrf52 series...
Parents
  • I am confused at this point. I've read through the various headers and the data sheet for the nRF52840 and they all say the TXD.MAXCNT is a 16-bit value.

    I've been able to read > 256 bytes in one call no problem. The trouble is the tx can send only 251 at once so far. I've read through many cases on the devzone, and haven't really seen anyone else clear this up completely.

    I'm using the latest SDK 17.2. Not sure where in the code this weird restriction takes place.

    I am missing a step here? I have attempted to set the TXD.MAXCNT variable. This is fine, but the call to static spim_xfer will override this anyway to whatever value setup via the nrfx_spim_xfer_desc_t data structure. Is there some other register that needs to be set globally?

Reply
  • I am confused at this point. I've read through the various headers and the data sheet for the nRF52840 and they all say the TXD.MAXCNT is a 16-bit value.

    I've been able to read > 256 bytes in one call no problem. The trouble is the tx can send only 251 at once so far. I've read through many cases on the devzone, and haven't really seen anyone else clear this up completely.

    I'm using the latest SDK 17.2. Not sure where in the code this weird restriction takes place.

    I am missing a step here? I have attempted to set the TXD.MAXCNT variable. This is fine, but the call to static spim_xfer will override this anyway to whatever value setup via the nrfx_spim_xfer_desc_t data structure. Is there some other register that needs to be set globally?

Children
No Data
Related