Out of Sequence

You inherited the drive firmware for a small brushless motor. A brushless motor only makes torque when the bridge energizes the phase that lines up with where the rotor is right now, so the loop reads the rotor's hall sector every millisecond, looks up the phase to energize in a commutation table, and eases the PWM duty toward a commanded speed.

A colleague handed it over as working, but on the rig the shaft will not turn at all. The drive is enabled, the duty winds all the way up to full, the controller is clearly trying, and the shaft just sits there. No fault is reported, and it behaves the same no matter where the rotor happens to be resting when it starts.

The commanded setpoint is delivered in an SRAM mailbox at 0x2000FF00 in milli-RPM (900,000 mRPM is 900 RPM). The rotor's present sector is reported in HALL as a value 1 through 6, and the phase to energize is written to COMMUTATE. A correct drive spins up smoothly to the commanded speed and the hall sector steps cleanly through 1, 2, 3, 4, 5, 6 and around again, from whatever sector the rotor happened to start in.

Find why the shaft will not turn and fix it so it spins up to the commanded speed from any starting position.

Loading the interactive arena.