I have a DFrobot motor shield that runs on analog pins 5+6, so trying to get myjavascript:void(0); DC motor to run on speeds that are not the maximu, I tried to switch to fast PWM and phase-correct PWM according to the last paragraph in this tutorial:
http://arduino.cc/playground/Main/TimerPWMCheatsheet
I also modified wiring.c as described (1510 for phase-correct, 1256 for fast PWM). However, timers still seem to be quite a bit off. Strange things happen when running the Servo lib example code:
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
servo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
When phase-correct PWM is enabled the servo moves from left to right very fast, when fast PWM is enabled, it just jitters around. Does this mean that timer0 is still off even after modifying wiring.c? The DC motor only responds in the 170-255 range.
Also, I use the serial port to send values for the servo (0-180) , which are put together from two back to back bytes:
servoAngle = (Serial.read() & 0xff) << 8;
servoAngle = servoAngle | (Serial.read() & 0xff);
Without messing with PWM modes, the values arrive correctly, with modifications to the PWM frecquency all it receives is -1.