Hi, bin Anfänger und hoffe, dass mir jemand hilft. Wollte ein wenig mit PWM mich beschäftigen - nur habe anscheinend einen Fehler drin - die Frequenz soll größer und kleiner werden - das funktioniert auch - allerdings gibt es immer wieder "Aussetzer" (Ausgang dann auf low) und ich weiß nicht warum
1 | #include <stdint.h> |
2 | #include <avr/io.h> |
3 | |
4 | |
5 | int main() |
6 | {
|
7 | |
8 | uint16_t test,test2; |
9 | uint16_t t2; |
10 | |
11 | DDRB=0b00000110; |
12 | |
13 | TCCR1A = (1<<COM1A1) | (1<<WGM11); |
14 | TCCR1B = (1<<WGM13) | (1<<WGM12) | (1<<CS12); |
15 | |
16 | |
17 | |
18 | |
19 | start:
|
20 | |
21 | |
22 | t2=600; |
23 | test2=0; |
24 | |
25 | |
26 | |
27 | while(test2<600){ |
28 | test2++; |
29 | while (test<1000){test++;}; |
30 | test=0; |
31 | |
32 | t2++; |
33 | |
34 | OCR1A=(t2 / 2); |
35 | ICR1=t2; |
36 | }
|
37 | |
38 | test2=0; |
39 | |
40 | while(test2<600){ |
41 | test2++; |
42 | while (test<1000){test++;}; |
43 | test=0; |
44 | t2--; |
45 | |
46 | OCR1A=(t2 / 2); |
47 | ICR1=t2; |
48 | }
|
49 | |
50 | |
51 | |
52 | |
53 | goto start; |
54 | return 0; |
55 | }
|