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.
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.
I made some logical updates which make the code make more sense to me. This handles the offset issue I described previously.
Hi,
Not certain the first approach you suggest is the best, since it re-write the write buffer in RAM with what's showing up on the MISO at the same time as it sends out data on MOSI. In theory the peripheral is probably done reading the relevant byte from RAM before the transfere starts.
255 byte limit is correct for the nRF52832 SPIM, witch is a 8-bit MAXCNT register.
If you wish to send longer packages i would recommend to migrate to nrfx_spim as a alternative to nrf_drv_spi diver.
Regards,
Jonathan
I switched to use the nrfx_spim driver. I was able to remove the legacy spi driver as far as I can tell.
I updated the xfer function to look like:
Here is a overview of the MAXCNT registers for peripherals on each 52 chip: https://infocenter.nordicsemi.com/topic/struct_nrf52/struct/nrf52.html?cp=4
Using nrfx_spi supports longer transfers but since it is legacy SPI peripheral the CPU need to be updated the byte that is sendt\received for each byte.
nrfx_spim will allow you to use 16bit lengths, (65535 bytes) per transfer.
Regards,
Jonathan
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?