I am using XIAO nRF52840 SENSE.
I want to get IMU data via DMA @ 104Hz, PDM data @16kHz/41.667kHz, and send the data via BLE @ 247,1M, gap = 7.5ms.
when enable IMU, disable PDM, the IMU data can be send via BLE correctly.
when enable both IMU and PDM, the BLE is disconnected, the IMU data are also correct.
when enable both IMU and PDM, and connected BLE and send realtime data. the IMU data will be about 0 in some frame. about 1 frame in 10 frames.
In the situation, the IMU data from DMA buffer are already 0, so I think it is none business of send data via BLE or parse data.
I try to change PDM from 41.667kHz to 16kHz, it appears no improvement.
Anyone know why and what happened. What can I do to solve this problem?
SO , it’s been a minute, always good stuff you bring and ask
Its a contention issue, the BLE (radio is the highest interrupt priority), the DMA is next, the PDM is LAST
the BLE interuppts causes a delay in returning he DMA start memory location basically, the short connection interval cuases that. The PDM has on ly a two sample buffer so it complicates the DMA and the data gets a ZERO…
Switch to DPPI /PPI
Do not rely on CPU interrupts to trigger the next IMU DMA transfer. Use hardware PPI/DPPI to connect the IMU data-ready GPIO pin directly to the SPI/I2C START task. This eliminates CPU interrupt latency from the transfer trigger path.
Also Increasing the interval to 15 ms–30 ms while transmitting multiple packets per connection event gives the CPU larger continuous time slices to handle peripheral ISRs and buffer swapping.
Check your dev tree and Kconfig for proper priority in Zephyr and with IMU instead of the PING-PONG double buffer , use a fifo 3 or 4 elements for the Queue so a brief delay in consumption does not result in reading an empty/unpopulated slot.