During an execution of a winbond w25q64jv command (any command) during a BLE_GATTS_EVT_WRITE event the SPI bus goes inactive after the command is sent:

There is apparently no issue if I do any NVM operation outside a BLE_GATTS_EVT_WRITE event.
During an execution of a winbond w25q64jv command (any command) during a BLE_GATTS_EVT_WRITE event the SPI bus goes inactive after the command is sent:

There is apparently no issue if I do any NVM operation outside a BLE_GATTS_EVT_WRITE event.
Hello,
ccrider said:I am not waiting for a callback.
That sounds like a reasonable workaround. However, I am still not sure what you are doing in your snippets.
ccrider said:I added a call to the NVM function (Test_write_and_read_of_NVM();) that is known to work was added here:
Do you refer to the Test_write_and_read_of_NVM()?
Is Test_write_and_read_of_NVM() the same as in your previous snippet?
ccrider said:
Where? Is it stuck here?
while (!spi_xfer_done)
{
__WFE();
}
ccrider said:I am not waiting for a callback.
So where is "spi_xfer_done" being changed?
My suspection is that you are waiting for a callback to set spi_xfer_done to true, but this callback will not be executed because you are waiting in another callback with the same or higher priority.
So there are two workarounds for this:
1: In your on_Command_write() callback, just set a flag or something, and then handle the SPI transfer from the main context later.
2: Increase the spi IRQ priority. You can set it to 2 or 3, as described here. The way you set it is in sdk_config.h. Search for SPI_IRQ_PRIORITY and NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY and set them both to e.g. 3.
Best regards,
Edvin