Skip to main content
NewEpisode 8a is out: Two state machines 1: rising edgeWatch →

This part is for members

Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.

Keep watching the free parts
Skeleton · 6e

Four gates 5: who interrupts whom

At 1102.55 ms the position loop leaves an iq target of 0.0118 A in kAxis.current_ctl_input, and the current loop reads it at 1102.6 ms. CommandCurrentFilter writes the five fields one by one, with no lock: read halfway, they would pair a new angle with an old target (like copying a whiteboard someone is halfway through rewriting). Can it happen? The priorities are ADC 2, TIM5 3, TIM13 5, all preempting under group 4, so the current loop can cut into the position loop. What protects the handover is the fixed phase from 6b: each position tick starts right after a current interrupt and has almost 50 µs (worked out from the code; the bench never nests interrupts). Then what the DWT stopwatch hides: it measures elapsed time (interruptions included), the host reads the previous tick and only the latest one, and the 1 ms task's records are never used. The bench's cycles only show the arithmetic is right; the run times are a Mac's, not the M7's. A one-page summary closes Episode 6.

Up next7a · Current sampling 1: when in the PWM period→