I'm attempting to obtain data from a sensor at a 4 KHz rate. Specifically, I get a pulse every ~0.250 ms that indicates that data is ready to read. To actually read the data I need to use the SPI (running at 4MHz) to read two values.
I'm using the pulse to activate an interrupt. The interrupt handler simply sets a semaphore for the "reading" task (thinking that doing the actual SPI read in the interrupt handler would take too long.). The "reading" task performs the SPI reads and sends the data.
I'm running this on a CC2640. I see the data start to arrive, but after a very short time, the CC2640 starts to miss the data. I'm guessing that the BLE services, running at a higher priority, are taking up too many CPU cycles.
I'm running the "reading" task at priority level 2. My other tasks run at priority level 1. All of the system level (and BLE) tasks run at higher levels.
I am using the highest level of optimization.
I thought that the sensor controller might be a good way to offload the data collection duties, but it appears from reading that the only SPI interface available to it is a software implemented SPI. Is there "optimized" SPI code for the sensor controller available? Is there a way for the sensor controller to access the HW SPI module?
Any other ideas on how to achieve the 4 KHz sampling rate?
Thanks!