constrain(u, 0, 255);
Since constrain() returns the constrained value you probably want:
u = constrain(u, 0, 255);
It might work better is you calculate the PID before you set the direction:
err_dot = err - err_old;
err_intgrl = err + err_intgrl;
int PID = Kp*err + Kd*err_dot + Ki*err_intgrl;
constrain(PID, -255, 255);
if (PID < 0) {
setDirection(LOW, HIGH);
PID = -PID;
}
else
setDirection(HIGH, LOW);
analogWrite(EnA, PID);