Hi,
My project uses nRF52840 with SD 140, SDK 17.0.2 and SES. My hardware has SD Card SPI and LCD SPI sharing bus pins, using CS pins to switch devices. Because of this each device needs to be uninitialized before starting comms with the other. Essentially my code flow goes:
Initialize SD card -> Read bmp file from SD -> Uninitialize SD -> Initialize LCD -> Display bmp on screen -> Uninitialize LCD
This all works fine when called from my main() function. I can display as many bmp images in a row as I desire. The problem occurs once the event loop has started. Both the SD card and LCD will not initialize from an event handler function. The SD card hangs at m_drives[drv].config.wait_func(); in diskio_blkdev.c or the LCD hangs at while(!m_spi_xfer_done) after calling nrfx_spim_xfer();. I have tried using a bsp event (pressing board button) and also a ble write event (writing to custom characteristic). I have tried using SPI Instances 0, 1, and 2 with same results.
I don't understand how it can initialize and unitialize 10 times in a row with no issues before any event handlers run but it seems deadlocked afterwards? It seems to me there could be an issue with the soft device causing interference with the spi bus?
EDIT: It appears I might have an interrupt issue? But if I set NRFX_SPIM and SPI_ENABLED irq priority to 3 or 5 I get hard fault when event handler routine is called