Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/interrupt.h>
- volatile uint8_t count = 0;
- void timer1_init ()
- {
- OCR1A = 57599;
- TIMSK |= 16; //Output compare interrupt enable
- TCCR1B |= (1<<CS12) | (1<<WGM12); //256x pre-scaler
- sei(); //global interrupt enable
- }
- ISR (TIMER1_COMPA_vect)
- {
- if (count)
- {
- count = 0;
- PORTB |= (1<<PB0);
- OCR1A = 633;
- }
- else
- {
- count = 1;
- PORTB &= ~(1<<PB0);
- OCR1A = 518;
- }
- }
- int main(void)
- {
- PORTB = 0b00;
- DDRB |= (1<<PB0) | (1<<PB1);
- timer1_init();
- while(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement