I do have such a reason, so I have to use registers.
And, I found these in the datasheet of ATmega328p:
Blockquote
To do a 16-bit write, the high byte must be written before the low byte. For a 16-bit read, the low byte must be read before the
high byte.
and, I wrote this:
void setup() {
// put your setup code here, to run once:
TCCR1A|=(1<<COM1A1)|(1<<COM1B1)|(1<<WGM11)|(1<<COM1A0)|(1<<COM1B0); //NON Inverted PWM
TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11)|(1<<CS10); //PRESCALER=64 MODE=14(FAST PWM)
//TCCR1B|=(1<<WGM13)|(1<<WGM12)|(1<<CS11); //PRESCALER=8 MODE=14(FAST PWM)
DDRB|= (1<<PB1)|(1<<PB2); //PWM Pins as Output
//ICR1=39999; //fPWM=50Hz
ICR1=4999; //fPWM=50Hz
}
void loop() {
// put your main code here, to run repeatedly:
OCR1AH = highByte(250);
OCR1AL = lowByte(250);
//OCR1A = 250;
delay(1000);
OCR1AH = highByte(375);
OCR1AL = lowByte(375);
delay(1000);
OCR1AH = highByte(500);
OCR1AL = lowByte(500);
//OCR1A = 500;
delay(1000);
It still didn't work.
and this:
ICR1H = highByte(4999);
ICR1L = lowByte(4999);
I could only heard some noise form the servo.