/*
* Example10_10.c
*
* Created: 05/02/2017 12:16:22
* Author: Naimi
*/
#include "avr/io.h"
#include "avr/interrupt.h"
int main ( )
{
DDRB |= (1<<1)|(1<<3); //make DDRB.1 and DDRB.3 output
DDRC = 0x00; //make PORTC input
PORTC = 0xFF; //enable pull-up
DDRD = 0xFF; //make PORTD output
TCNT0 = -160;
TCCR0A = 0x00;
TCCR0B = 0x01; //Normal mode, int clk, no prescaler
TCNT1H = (-1600)>>8; //the high byte
TCNT1L = (-1600); //the low byte
TCCR1A = 0x00;
TCCR1B = 0x01;
TIMSK0 = (1<<TOIE0); //enable Timers 0 interrupt
TIMSK1 = (1<<TOIE1); //enable Timers 1 interrupt
sei (); //enable interrupts
while (1) //wait here
PORTD = PINC;
}
ISR (TIMER0_OVF_vect) //ISR for Timer0 overflow
{
TCNT0 = -160; //TCNT0 = -160 (reload for next round)
PORTB ^= (1<<1); //toggle PORTB.1
}
ISR (TIMER1_OVF_vect) //ISR for Timer0 overflow
{
TCNT1H = (-1600)>>8;
TCNT1L = (-1600); //TCNT1 = -1600 (reload for next round)
PORTB ^= (1<<3); //toggle PORTB.3
}