Hello we are using custom board nrf52840 with nRF SDK 15.2.0 on SEGGER Embedded Studio
I hope someone can help me with this issue. I am using SPIM3 to communicate with the NAND Flash AS5F18G04SND-10LIN (1GB). The read/write functions for communicating with the flash work very well, reading and writing data accurately. Recently, I wanted to add the USB MSC feature, so I wrote a custom block device (I referred to the block devices for SD card and RAM). My NAND flash has a write block size of 4096, so I configured my USB MSC as NRF_BLOCK_DEV_SPI_CONFIG(4096, 4096*64), and #define MSC_WORKBUFFER_SIZE (4096).
However, for some reason, when the USB MSC calls the read/write functions via SPIM3, the interrupt does not trigger EVENTS_END, causing the read/write functions to hang. I referred to the nRF52840 Errata [193] SPIM: SPIM3 does not generate EVENTS_END and halts if suspended during the last byte. I also tried restarting SPIM3 after a countdown if EVENTS_END did not trigger. Now, my program does not hang anymore. On my PC (Windows 10), I can see the files on my NAND flash.
However, the real issue starts here. After checking the data in the files from the PC, I discovered that data is lost periodically. I noticed that the data loss occurs whenever SPIM3 hangs. The solution for Errata [193] only prevents my read/write functions from hanging but does not truly resolve the issue of data not being read correctly or other errors. I also tried referring to Errata [198] and enabled #define NRFX_SPIM3_NRF52840_ANOMALY_198_WORKAROUND_ENABLED 1, but it was not effective. As soon as USB power is applied, the program dumps.
My read/write functions work well on their own; however, they have issues when used inside block_dev_spi_read_req
or block_dev_spi_write_req
. I am unsure if the USB MSC backend affects SPIM3.
Do you have any suggestions or solutions for this issue? Thanks