Flavio G. schrieb:
> main()
> {
> //pwm:
> TCCR0 = (1<<CS00)|(1<<WGM01)|(1<<WGM00)|(1<<COM01);
> OCR0 = 0;
>
> //timer als clock für timestepping
> TCCR2 =(1<<WGM21) |(1<<CS21)|(1<<CS20);
> OCR2=250;
> //Compare Interrupt aktivieren
> TIMSK|=(1<<OCIE2);
> //Globale Interrupts aktivieren
> sei();
>
> ISR (TIMER2_COMP_vect){
> //mache irgendwas
>
> }
> while(1){}
> }
>
In C kann man nicht Funktionen ineinander schachteln.
Ich weiß, der gcc hat eine Erweiterung, die das möglich macht. Man
sollte es aber trotzdem nicht tun
1 | ISR (TIMER2_COMP_vect)
|
2 | {
|
3 | }
|
4 |
|
5 | main()
|
6 | {
|
7 | //pwm:
|
8 | TCCR0 = (1<<CS00)|(1<<WGM01)|(1<<WGM00)|(1<<COM01);
|
9 | OCR0 = 0;
|
10 |
|
11 | //timer als clock für timestepping
|
12 | TCCR2 =(1<<WGM21) |(1<<CS21)|(1<<CS20);
|
13 | OCR2=250;
|
14 | //Compare Interrupt aktivieren
|
15 | TIMSK|=(1<<OCIE2);
|
16 |
|
17 | //Globale Interrupts aktivieren
|
18 | sei();
|
19 |
|
20 | while(1)
|
21 | {
|
22 | }
|
23 | }
|
Ansonsten ist da erst mal nichts auffällig, was die Funktion verhindern
könnte.