Code: Select all
TCCR3A |= (1<<WGM31); // phase correct mode
TCCR3A &= ~(1<<WGM30);
TCCR3B |= (1<<WGM33);
TCCR3B &= ~(1<<CS31); // no prescaler
ICR3 |= 0x3FFF; // TOP to 16383;
instead of making a clean and precise statement like this
Code: Select all
TCCR3A = (1<<WGM31);
TCCR3B = (1<<WGM33) | (1<<CS30); // phase correct mode no prescaler
ICR3 = MOTOR_RATE;
which is simpler, less prone to errors, shorter, faster, and incredibly sexy.
Same repeats for TCCR4A a few lines down.
I would be glad to unfuck this for you ...