Hallo Zusammen .... Ich hab diese Funktion <util/delay.h> mit ATmega16 versucht zu benutzen. Aber die Zeit nicht so stimmt. zB. Ich hab auf 80us gesetzt, aber sie kommt auf 990us aus. Ich habe schon mit FUSE Bit korrigiert, das schon richtig ist. Die Quarz ist auch richtig 4Mhz. Woran kann die Problem noch legen, oder mich etwas flash gemacht Danke für eure Hilfe ... Gruß PaMan
1 | #include <avr/interrupt.h> |
2 | #include <avr/io.h> |
3 | #include <stdint.h> |
4 | |
5 | #ifndef F_CPU
|
6 | #define F_CPU 4000000UL /* Quarz 4 Mhz */ |
7 | #endif
|
8 | #include <util/delay.h> |
9 | /******************************************************************************/
|
10 | |
11 | int main (void) |
12 | {
|
13 | |
14 | DDRA = 0xFF; // Set PortA as Output |
15 | |
16 | DDRB = 0b11111010; // PB3( OC0 as Output) PB0(T0 as Input) PB2(SW as Input) |
17 | PORTB = 0b00000101; // Pull Up Input Pin |
18 | |
19 | PORTA |= (1<<PORTA0); // Pre Show |
20 | |
21 | |
22 | |
23 | while(PINB & (1<<PINB2)); // wait switch Clear (Loop until bits clear) |
24 | PORTA &= ~(1<<PORTA0); // switch Confirm clear pre show |
25 | |
26 | while(1) |
27 | {
|
28 | _delay_us(80); |
29 | |
30 | PORTA |= (1<<PORTA1); |
31 | |
32 | _delay_us(80); |
33 | |
34 | PORTA &= ~(1<<PORTA1); |
35 | }
|
36 | |
37 | }
|