void setup()
{
DDRB = 0b00000110; //pin 9, 10 as output
PORTB = PINB | 0b00000100; //set pin 10 high
TCCR1A = 0b00000000; //TCCR1A bit 0, 1 and TCCR1B bit 3, 4 set timer mode
TCCR1B = 0b00001101; //Set mode to be clear on compare. set scaler to be clock/1024
OCR1A = 1562; //period = (OCR1A/B + 1)*scaler*62.5ns = 100ms
TIMSK1 = 0b00000010; //enable timer counter
sei();
}
void loop()
{
}
ISR (TIMER1_COMPA_vect){
PORTB ^= 0b00000110; //toggle pin 9, 10
printBin(PINB);
}
reference:
lm393 comparator
No comments:
Post a Comment