Leute ich seh den Fehler nicht, ich will an Pin A3 eine PWM erzeugen aber der Timer läuft irgendwie nicht an ... hier mal der eigentlich kurze Code, sieht da jemand einen Fehler? Eigentlich sollte der doch laufen, hat sonst noch jemand eine idee?
1 | #include <stdlib.h> |
2 | #include <avr/io.h> |
3 | #include <avr/interrupt.h> |
4 | //#include <avr/pgmspace.h>
|
5 | //#include <inttypes.h>
|
6 | //#include <avr/eeprom.h>
|
7 | //#include <string.h>
|
8 | //#include <util/delay.h>
|
9 | //#include <avr/wdt.h>
|
10 | |
11 | /* define CPU frequency in Mhz here if not defined in Makefile */
|
12 | #ifndef F_CPU
|
13 | #define F_CPU 14745600UL
|
14 | #endif
|
15 | |
16 | |
17 | |
18 | |
19 | #define LED_DDR DDRA
|
20 | #define LED_PORT PORTA
|
21 | |
22 | #define LED1 0
|
23 | #define LED2 1
|
24 | |
25 | #define P_PORT PORTA
|
26 | #define P_DDR DDRA
|
27 | #define P1_PIN 3
|
28 | #define P2_PIN 4
|
29 | |
30 | |
31 | |
32 | |
33 | ISR(TIMER0_OVF_vect) |
34 | {
|
35 | P_PORT |= (1<<P1_PIN); |
36 | |
37 | }
|
38 | |
39 | ISR(TIMER0_COMP_vect) |
40 | {
|
41 | |
42 | P_PORT &= ~(1<<P1_PIN); |
43 | }
|
44 | |
45 | |
46 | |
47 | |
48 | |
49 | int main(void) |
50 | {
|
51 | |
52 | TCCR0 |= (1<<CS02) | (1<<CS00); |
53 | OCR0 = 0x80; |
54 | |
55 | P_DDR |= (1<<DDA3); |
56 | P_DDR |= (1<<DDA4); |
57 | |
58 | |
59 | sei(); |
60 | |
61 | TIMSK |= (1<TOIE0) | (1<<OCIE0) ; |
62 | P_PORT |= (1<<P1_PIN); |
63 | |
64 | while(1) |
65 | {
|
66 | |
67 | return 0; |
68 | |
69 | }
|
70 | }
|