Interrupt-driven pulse sequencer (source code)

= Interrupt-driven pulse sequencer

A pulse sequencer can separate event capture from output timing. A short <interrupt handler> acknowledges the <event latch> and increments a pending count. An independent <finite-state machine> consumes one count on entering `ON`, changes to `GAP` after the pulse width, and enters `IDLE` only after the mandatory off interval. Even an empty queue must not bypass `GAP`: an arrival immediately after light-off would otherwise start too soon.

The pending count equals recorded events minus started pulses. A <critical section> protects its read-modify-write operations; declaring shared state as in <volatile-qualified objects in C> does not alone make each update an <atomic operation>. Separate sequencers for different channels allow simultaneous pulses while one <hardware timer> schedules their earliest deadline. Finite queue capacity, detector rearming and dispatch resolution remain explicit assumptions.