I am working with a fast loop (0.5 ms cycle time) and slow loop (10 ms cycle time) which communicate with each other. How can I make the in- and outputs to be consistent?
Consider the example below, I want the assignments in the SlowLoop to be atomic, to be sure that both referenced inputs from the FAST loop correspond with values from the same cycle.
Example
FastLoop [0.5 ms]
FAST_CNT = some rising edge detection
FAST_RUNIDX += 1
SlowLoop [10 ms]
<-- Atomic Operation
pulseCount = FAST_CNT
elapsedTicks = FAST_RUNIDX
Atomic Operation -->