SHOW:
|
|
- or go back to the newest paste.
1 | #include<avr/io.h> | |
2 | ||
3 | ||
4 | ||
5 | int main(void){ | |
6 | - | TCCR0 |= (1<<CS00);// | (1<<CS01); |
6 | + | |
7 | - | TCCR0 |= ~(1<<CS01); |
7 | + | TCCR0 |= (1<<CS02) | (1<<CS00);// ustawienie preskalera na 1024 |
8 | ||
9 | //TCCR0 |= ~(1<<CS01); | |
10 | DDRA = 0xFF; | |
11 | ||
12 | while (1){ | |
13 | PORTA = 0x00; | |
14 | opuzn(200); | |
15 | PORTA = 0xFF; | |
16 | opuzn(200); | |
17 | } | |
18 | ||
19 | } | |
20 | ||
21 | int opuzn(int czas){ | |
22 | ||
23 | while(1){ | |
24 | ||
25 | if(TIFR & (1<<TOV0)){ | |
26 | TIFR |= (1<<TOV0); | |
27 | TCNT0 = 255 - czas; | |
28 | return 0; | |
29 | } | |
30 | } | |
31 | } |