I think I've resolved the issue, but limited testing has been performed.
I believe the issue was here:
void MotorStateMachine() { // update the SteppingRateTMR if required // reduce the number of calculations if (UpdateSteppingRateTMR == true) { SteppingRateTMR = SMCLK_FREQ/SteppingRate; // calculate new value UpdateSteppingRateTMR = false; // clear flag } switch (AccelerateState) { case (IDLE): if(G_RECIPROCATION == false && G_WAKE == high && G_ENABLE == high) { G_MOTOR_CMD_ACTIVE1 = false; G_MOTOR_CMD_ACTIVE2 = false; G_MOTOR_CMD_ACTIVE3 = false; G_ENBL_START_STOP = false; // enable with false, allow Start Stop G_MANUAL_ADVANCE = false; // clear the flags once stops G_ENBL_RECIPROCATION_BUTTON = false; G_RUN_MOTOR = false; G_ENBL_MOVE_STEPS = false; MoveSteps = false; // clear the MoveSteps flag here // reset the timers if the last command was run motor if (LastCommandWasRunSteps == true) { TACTL &= ~MC_3; // Stop timerA TBCTL &= ~MC_3; // Stop timerB } }
The IDLE case was running often, and clobbering all of the GUI writes to those GLOBALS before DetermineMotorMovement() could take action on them. I added a PrevAccelerateState variable, and set it to AccelerateState just before each time it changed.
Now the UpdateStateMachine() only clears the GLOBALS on the first transition into IDLE:
void MotorStateMachine() { // update the SteppingRateTMR if required // reduce the number of calculations if (UpdateSteppingRateTMR == true) { SteppingRateTMR = SMCLK_FREQ/SteppingRate; // calculate new value UpdateSteppingRateTMR = false; // clear flag } switch (AccelerateState) { case (IDLE): { if (PrevAccelerateState == IDLE) { // do nothing, make sure we only clear the globals listed below once on a state change } else { PrevAccelerateState = IDLE; // Set state to idle if(G_RECIPROCATION == false && G_WAKE == high && G_ENABLE == high) { G_MOTOR_CMD_ACTIVE1 = false; G_MOTOR_CMD_ACTIVE2 = false; G_MOTOR_CMD_ACTIVE3 = false; G_ENBL_START_STOP = false; // enable with false, allow Start Stop G_MANUAL_ADVANCE = false; // clear the flags once stops G_ENBL_RECIPROCATION_BUTTON = false; G_RUN_MOTOR = false; G_ENBL_MOVE_STEPS = false; MoveSteps = false; // clear the MoveSteps flag here // reset the timers if the last command was run motor if (LastCommandWasRunSteps == true) { TACTL &= ~MC_3; // Stop timerA TBCTL &= ~MC_3; // Stop timerB } } } }
I'll leave a CCS 7.2.0 project here in case anyone else has this issue, this FW image calls itself v1.1.
Thanks,
Adam
(Please visit the site to view this file)