- When tested on a bare-metal architecture (via Segger Embedded Studio), this worked perfectly with zero timing issues.
- However, when ported over to Zephyr RTOS, where the TimeSync loop was managed via threads (including the
mainthread) alongside multiple heavy worker threads handling the sensor data stream, the application struggled heavily. I experienced frequentMPSL_TIMESLOT_SIGNAL_BLOCKEDand slot cancellation events, which regularly corrupted my synchronized data dataset.
- By leveraging these hardware-level connection event timings to synchronize the master clocks, our synchronization delay is now completely stable at a maximum of 5 µs(this is what i could observe on the logic analyzer).
- The phase correction from the reference signal is perfectly preserved, even though the rest of the Sensor Node firmware still relies heavily on Zephyr threads for high-speed sensor processing and storage.
- RTOS Context-Switching Latency: While bare-metal handles MPSL signals instantly in an ISR, handling data inside Zephyr threads introduces context-switching overhead (around 5–20 µs). By the time a thread wakes up to calculate and request the next timeslot via
mpsl, the calculated absolute timeline is already stale or conflicting with a hard BLE deadline, causing MPSL to reject it. - Driver Interrupt Masking (Critical Sections): The background threads on my sensor node rely heavily on SPIM, TWIM, and flash storage. I suspect these drivers call
irq lockor mask interrupts briefly during transfers, delaying the core execution of the MPSL hardware timers just enough to fall out of bounds.
- Is my hypothesis correct regarding why MPSL timeslots struggle heavily under a thread-heavy Zephyr environment compared to bare-metal?
- By moving to BLE connection-interval-based synchronization, am I correct in assuming that the time-stamping of the reference signal occurs purely at the hardware/controller layer, making the master clock synchronization entirely immune to the jitter, preemption, or interrupt masking caused by upper-layer Zephyr threads?
- Are there any hidden risks to watch out for when using BLE connection events for continuous clock drift compensation while heavy DMA-backed threads (SAADC/SPIM) are actively sampling on the sensor node?