Subversion Repositories group.electronics

Rev

Rev 17 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 65
Line 27... Line 27...
27
	cbi(DDRB, PCINT2);
27
	cbi(DDRB, PCINT2);
28
	cbi(DDRB, PCINT3);
28
	cbi(DDRB, PCINT3);
29
 
29
 
30
	TIMSK = (1<<TOIE0);                   // Eable timer overflow for Timer0
30
	TIMSK = (1<<TOIE0);                   // Eable timer overflow for Timer0
31
	TCNT0 = 0x00;                         // Set Timer0 to 0
31
	TCNT0 = 0x00;                         // Set Timer0 to 0
32
	TCCR0B = (1<< CS02) | (1<<CS00);      // /1024 prescaler
32
	TCCR0B = (1<< CS01) | (1<<CS00);      // /1024 prescaler
33
 
33
 
34
	PORTB |= (( 1 << PCINT2 ) | ( 1 << PCINT3 )); //turn on pullups
34
	PORTB |= (( 1 << PCINT2 ) | ( 1 << PCINT3 )); //turn on pullups
35
	PCMSK |= (( 1 << PCINT2 ) | ( 1 << PCINT3 )); //enable encoder pins interrupt sources
35
	PCMSK |= (( 1 << PCINT2 ) | ( 1 << PCINT3 )); //enable encoder pins interrupt sources
36
	sei();
36
	sei();
37
	GIMSK |= ( 1 << PCIE ); //enable pin change interupts
37
	GIMSK |= ( 1 << PCIE ); //enable pin change interupts
Line 55... Line 55...
55
			doInt();
55
			doInt();
56
	}
56
	}
57
}
57
}
58
 
58
 
59
void doInt() {
59
void doInt() {
60
  xbi(PORTD, PD6);
60
//  xbi(PORTD, PD6);
61
 
61
 
62
  if (rbi(pcIntCurr, PCINT2) == 0 && rbi(pcIntCurr, PCINT3) == 0 && rbi(pcIntMask, PCINT2) ) {
62
  if (rbi(pcIntCurr, PCINT2) == 0 && rbi(pcIntCurr, PCINT3) == 0 && rbi(pcIntMask, PCINT2) ) {
63
	cbi(PORTD, PD5);
63
	cbi(PORTD, PD5);
64
	sbi(PORTD, PD4);
64
	sbi(PORTD, PD4);
65
	time_rot = 5;
65
	time_rot = 5;
Line 73... Line 73...
73
}
73
}
74
 
74
 
75
ISR(TIMER0_OVF_vect) {
75
ISR(TIMER0_OVF_vect) {
76
        timer0_ovf++;
76
        timer0_ovf++;
77
 
77
 
-
 
78
  xbi(PORTD, PD6);
-
 
79
 
78
        if (time_rot) {
80
        if (time_rot) {
79
                time_rot--;
81
                time_rot--;
80
        }
82
        }
81
}
83
}
82
 
84