truncated 16bit timer registers

@pete: thanks for another tip

@cody: i grew tired of being in blind, so i got me multimeter which can measure freq, ut61e.
i am measuring frequency and duty cycle on the pin 10 of arduino micro.
the duty cycle would be 50% when ok, ~25% on failure.

there is another pwm mode, which instead of ICR1 uses OCR1A for top, setting frequency.
in this case not only duty cycle, but also the frequency would be affected by the truncated register.
(easier to measure, if you can not measure duty)

but i assume even without external measuring, if i had read TCCR1B after setting it, i would get a mismatch, which i could indicate via serial or blinking led.
(but that is just my assumption, i have not tried that)

------ this works ------
#include <avr/io.h>
#include <util/delay.h>

#define BLINK_DELAY_MS 500

int main (void)
{
/* set most pins for output*/
DDRC = 0xFF;
DDRB = 0xFF;

ICR1 = 999; //freq
OCR1B = 500; //duty

TCCR1A = 0;
TCCR1B = 0;

TCCR1A |= _BV(WGM11);
TCCR1B |= _BV(WGM12) | _BV(WGM13);
//Clear OCnA/OCnB/OCnC on compare match when up-counting. Set OCnA/OCnB/OCnC on compare match when down-counting.
TCCR1A |= _BV(COM1B1);
//prescake 1x
TCCR1B |= _BV(CS10);

//disable all timer1 inreupts, not needed, just to be sure
TIMSK1 = 0;

while(1) {
/* set pin 5 high to turn led on */
//PORTB |= _BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);

PORTC ^= 0xFF;

/* set pin 5 low to turn led off */
//PORTB &= ~_BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);
}
}
--------- end ----------

----- this fails ------
void setup() {
// put your setup code here, to run once:
DDRC = 0xFF;
DDRB = 0xFF;

ICR1 = 999;
OCR1B = 500;

TCCR1A = 0;
TCCR1B = 0;
//FastPWM ICRA = TOP
//TCCR1A |= _BV(WGM11) | _BV(WGM10);
TCCR1A |= _BV(WGM11);
TCCR1B |= _BV(WGM12) | _BV(WGM13);
//Clear OCnA/OCnB/OCnC on compare match when up-counting. Set OCnA/OCnB/OCnC on compare match when down-counting.
TCCR1A |= _BV(COM1B1);
//prescake 1x
TCCR1B |= _BV(CS10);

//disable all timer1 inreupts, not needed, just to be sure
TIMSK1 = 0;
}

void loop() {
// put your main code here, to run repeatedly:

}
----- end ---------

------ this works again ----
void setup() {
// put your setup code here, to run once:
DDRC = 0xFF;
DDRB = 0xFF;

OCR1BH = 1;
ICR1 = 999;
OCR1BL = 244;

TCCR1A = 0;
TCCR1B = 0;
//FastPWM ICRA = TOP
//TCCR1A |= _BV(WGM11) | _BV(WGM10);
TCCR1A |= _BV(WGM11);
TCCR1B |= _BV(WGM12) | _BV(WGM13);
//Clear OCnA/OCnB/OCnC on compare match when up-counting. Set OCnA/OCnB/OCnC on compare match when down-counting.
TCCR1A |= _BV(COM1B1);
//prescake 1x
TCCR1B |= _BV(CS10);

//disable all timer1 inreupts, not needed, just to be sure
TIMSK1 = 0;
}

void loop() {
// put your main code here, to run repeatedly:

}
------ end ------