 }
 
 /* MOSFET STATES */
-void state0(double pwmfreq)
+void state0(double pwmfreq) //P2N3
 {
   PORT->Group[PORTA].OUTSET.reg = (1<<20);
   PORT->Group[PORTA].OUTSET.reg = (1<<19);
-//  PORT->Group[PORTA].OUTSET.reg = 110000000000000000000; //P2N3
-}
-
-void state1(double pwmfreq)
+}
+
+void state1(double pwmfreq) //P1N3
 {
   PORT->Group[PORTA].OUTSET.reg = (1<<15);
   PORT->Group[PORTA].OUTSET.reg = (1<<19);
-//  PORT->Group[PORTA].OUTSET.reg = 10001000000000000000; //P1N3
-}
-
-void state2(double pwmfreq)
+}
+
+void state2(double pwmfreq) //P1N2
 {
   PORT->Group[PORTA].OUTSET.reg = (1<<15);
   PORT->Group[PORTA].OUTSET.reg = (1<<16);
-//  PORT->Group[PORTA].OUTSET.reg = 11000000000000000; //P1N2
-}
-
-void state3(double pwmfreq)
+}
+
+void state3(double pwmfreq) //P3N2
 {
   PORT->Group[PORTA].OUTSET.reg = (1<<7);
-  PORT->Group[PORTA].OUTSET.reg = (1<<16);
-//  PORT->Group[PORTA].OUTSET.reg = 10000000010000000; //P3N2
-}
-
-void state4(double pwmfreq)
+  PORT->Group[PORTA].OUTSET.reg = (1<<16); 
+}
+
+void state4(double pwmfreq) //P3N1
 {
   PORT->Group[PORTA].OUTSET.reg = (1<<7);
   PORT->Group[PORTA].OUTSET.reg = (1<<18);
-//  PORT->Group[PORTA].OUTSET.reg = 1000000000010000000; //P3N1
-}
-
-void state5(double pwmfreq)
+}
+
+void state5(double pwmfreq) //P2N1
 {
   PORT->Group[PORTA].OUTSET.reg = (1<<20);
   PORT->Group[PORTA].OUTSET.reg = (1<<18);
-//  PORT->Group[PORTA].OUTSET.reg = 101000000000000000000; //P2N1
+}
+
+void stateGND() //N1N2N3
+{
+  PORT->Group[PORTA].OUTSET.reg = (1<<16);
+  PORT->Group[PORTA].OUTSET.reg = (1<<18);
+  PORT->Group[PORTA].OUTSET.reg = (1<<19);
 }
 

  
  else //otherwise if same coil being used, check for overcurrent. If over, disable. If under, update pwm
  {
    int coilCurrent = readCurrent(); //read current is very slow because analog read sucks
//    if (coilCurrent > currentThresh) // !!! may need to fully ground coil instead of just cutting and making floating !!!
//      disableMotor();
//    else
//      setPWM(correctedOutput);
  }
  long endtme = micros();
  if (!stateChangeFlag)
    Serial.println(endtme - starttime);
}

void disableMotor()
{
//  PORT->Group[PORTA].OUTCLR.reg = 111011000000010000000; //turns off all mosfets using registers

  PORT->Group[PORTA].OUTCLR.reg = (1<<15);
  PORT->Group[PORTA].OUTCLR.reg = (1<<20);
  PORT->Group[PORTA].OUTCLR.reg = (1<<7);


void moveMotor()
{
  bool reversed = 0;
  correctedOutput = Output;

