Subversion Repositories group.electronics

Rev

Rev 56 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 56 Rev 57
Line 15... Line 15...
15
volatile uint8_t pcIntCurr[3] = {0,0,0};
15
volatile uint8_t pcIntCurr[3] = {0,0,0};
16
volatile uint8_t pcIntLast[3] = {0,0,0};
16
volatile uint8_t pcIntLast[3] = {0,0,0};
17
volatile uint8_t pcIntMask[3] = {0,0,0};
17
volatile uint8_t pcIntMask[3] = {0,0,0};
18
 
18
 
19
volatile uint8_t tmr0_ovf = 0;
19
volatile uint8_t tmr0_ovf = 0;
20
volatile uint8_t tmr1_ovf = 0;
20
volatile uint8_t tmr2_ovf = 0;
21
volatile uint32_t systime = 0;
21
volatile uint32_t systime = 0;
22
volatile uint8_t lcdupdate = 0;
22
volatile uint8_t lcdupdate = 1;
23
 
23
 
24
uint8_t emblock[] = {	0B00011111,
24
uint8_t emblock[] = {	0B00011111,
25
			0B00010001,
25
			0B00010001,
26
			0B00010001,
26
			0B00010001,
27
			0B00010001,
27
			0B00010001,
Line 68... Line 68...
68
  PORTD		= 0B11100011;
68
  PORTD		= 0B11100011;
69
 
69
 
70
	PCMSK2 |= (( 1 << PCINT16 ) | ( 1 << PCINT17 )); //enable encoder pins interrupt sources
70
	PCMSK2 |= (( 1 << PCINT16 ) | ( 1 << PCINT17 )); //enable encoder pins interrupt sources
71
	PCICR |= ( 1 << PCIE2 ); //enable pin change interupts
71
	PCICR |= ( 1 << PCIE2 ); //enable pin change interupts
72
 
72
 
73
	TIMSK0 = (1<<TOIE0);			// Eable timer overflow for Timer0
73
	TIMSK0 = (1<<TOIE0);			// Enable 8bit timer overflow for Timer0
74
	TCNT0 = 0x00;				// Set Timer0 to 0
74
	TCNT0 = 0x00;				// Set Timer0 to 0
75
	TCCR0B = (1<< CS01) ;			// /8 prescaler
75
	TCCR0B = (1<< CS00) ;			// /1 prescaler
76
 
76
 
77
	TIMSK1 = (1<<TOIE1);			// Eable timer overflow for Timer1
77
	TIMSK2 = (1<<TOIE2);			// Enable 8bit timer overflow for Timer2
78
	TCNT1 = 0x00;				// Set Timer1 to 0
78
	TCNT2 = 0x00;				// Set Timer2 to 0
79
	TCCR1B = (1<< CS11 | 1 << CS10) ;			// /8 prescaler
79
	TCCR2B = (1<< CS21 | 1<<CS20 ) ;	// /8 prescaler
80
 
80
 
81
	sei();
81
	sei();
82
 
82
 
83
 
83
 
84
	i2c_master();
84
	i2c_master();
Line 133... Line 133...
133
	pcIntMask[pcint] = 0;
133
	pcIntMask[pcint] = 0;
134
}
134
}
135
 
135
 
136
ISR(TIMER0_OVF_vect) {
136
ISR(TIMER0_OVF_vect) {
137
	tmr0_ovf++;
137
	tmr0_ovf++;
138
	if (tmr0_ovf>=6) {
138
	if (tmr0_ovf>=62) {
139
		xbi(PORTD, PD0);
139
		xbi(PORTD, PD0);
140
		systime++;
140
		systime++;
141
		tmr0_ovf = 0;
141
		tmr0_ovf = 0;
142
	}
142
	}
143
}
143
}
144
 
144
 
145
ISR(TIMER1_OVF_vect) {
145
ISR(TIMER2_OVF_vect) {
146
	tmr1_ovf++;
146
	tmr2_ovf++;
147
	if (tmr1_ovf>=73) {
147
	if (tmr2_ovf>=78) {
148
		xbi(PORTD, PD4);
148
		xbi(PORTD, PD4);
149
		lcdupdate=1;
149
		lcdupdate=1;
150
		tmr1_ovf = 0;
150
		tmr2_ovf = 0;
151
	}
151
	}
152
}
152
}
153
		
153
		
154
	
154
	
155
 
155