Hallo Zusammen
Ich habe folgenden Code. Jedoch wird der OUTPUT_LED nie inkrementiert.
Setze ich diese Zeile jedoch in den Interrupt(Ist jetzt auskommentiert),
so wird der Output inkrementiert. Ich sehe das Problem nicht und stehe
voll auf dem Schlauch.
1 | uint8_t global_flag_1ms;
|
2 |
|
3 | ISR(TIMER0_COMPA_vect)
|
4 | {
|
5 | // Set global flag that 1ms passed
|
6 | global_flag_1ms = 1;
|
7 | // OUTPUT_LED ++;
|
8 | };
|
9 |
|
10 | int main(void)
|
11 | {
|
12 | // initialize all needed parts
|
13 | init();
|
14 | // Activate interrupts global
|
15 | sei();
|
16 |
|
17 |
|
18 | while (1)
|
19 | {
|
20 |
|
21 | // Start the routine just if the timer0 interrupt occurred and 1ms past
|
22 | if(global_flag_1ms == 1)
|
23 | {
|
24 | global_flag_1ms = 0;
|
25 | OUTPUT_LED ++;
|
26 | }
|
27 |
|
28 | }
|
29 | // Deactivate interrupts global
|
30 | cli();
|
31 | }
|
Danke für konstruktive Beiträge.
MfG