213 |
miho |
1 |
// Ukazkovy program pro blikani na vystupu PC0 |
|
|
2 |
// Predpoklada procesor ATmega8 v defaultnim nastaveni |
|
|
3 |
// (interni RC oscilator 1MHz). |
|
|
4 |
|
|
|
5 |
#define F_CPU 1000000UL // 1MHz je deaultni frekvence interniho RC oscilatoru |
|
|
6 |
#include <avr/io.h> |
|
|
7 |
#include <avr/delay.h> |
|
|
8 |
|
|
|
9 |
// Spozdeni o libovolny pocet ms |
|
|
10 |
void xDelay_ms(unsigned int Time) |
|
|
11 |
{ |
|
|
12 |
for(;Time!=0;Time--) |
|
|
13 |
_delay_ms(1); // Knihovni procedura ma velmi omezen |
|
|
14 |
} // maximalni cas spozdeni |
|
|
15 |
|
|
|
16 |
|
|
|
17 |
// Hlavni program |
|
|
18 |
int main() |
|
|
19 |
{ |
|
|
20 |
|
|
|
21 |
DDRC |=1; // Nastav port PCD0 jako vystup |
|
|
22 |
|
|
|
23 |
for(;;) // Nekonecna smycka |
|
|
24 |
{ |
|
|
25 |
PORTC |= 1; // Nastav 1 |
|
|
26 |
xDelay_ms(500); // Pockej 1/2 sekundy |
|
|
27 |
PORTC &= ~1; // Nastav 0 |
|
|
28 |
xDelay_ms(500); // Pockej 1/2 sekundy |
|
|
29 |
} |
|
|
30 |
|
|
|
31 |
return 0; |
|
|
32 |
} |