Dear all,
I have some problem with SPIs co-work.
I enabled two SPI instances in this project.
- SPI Instance 1 function(non blocking mode - DMA enabled, 4Mbps): reading data from SPI sensor while DRDY pin triggered by sensor
- SPI Instance 2 function(blocking mode - DMA enabled, 8Mbps): writing collected data to external FLASH sotrage
Rough frame of my software is:
- DRDY signal generated by sensor and trigger gpiote_handler
- SPI Instance 1 read and pack data from sensor in gpiote_handler(which might trigger SPI 1 handler several times)
- In main while loop, nRF52840 send data pack via ble then write the data pack to FLASH
The problem is, if I enable only SPI instance 1 to collect data and send it through ble, the received data is successive. But when I turn on both SPI instances at the same time, received data seems lost periodically every time I write data into FLASH. Seems like the problem is cuased by SPI conflicts but I highly doubt that since SPI instance 2 was set blocking mode and placed in main loop, which mean it could be interrupt by SPI instance one, right? P.S.: all of the IRQ priorities are default as 6, I tried to turn DRDY IRQ priority to 5 and SPI 1 priority to 4 but still suffered from packet lost.
Due to large data rate of sensor, DRDY signal comes quite frequently(about 8ms per signal), the window might not big enough for both getting data and saving data?
Anything wrong with my logic? Can I achieve this with other methods(for example use PPI to connect SPI instance 1 and DRDY pin so that I can spare CPU from getting data?)
Your help is appreciated and please make sure to let me know if any further information is needed?
Thanks,
Ava