Subversion Repositories svnkaklik

Rev

Rev 495 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
495 kaklik 1
#include <avr/io.h>
2
#include <inttypes.h>
3
#define F_CPU 1000000UL  // 1 MHz
4
#include <util/delay.h>
5
 
6
void delay_ms(unsigned int ms)
7
/* delay for a minimum of <ms> */
8
{
9
	// we use a calibrated macro. This is more
10
	// accurate and not so much compiler dependent
11
	// as self made code.
12
	while(ms){
13
		_delay_ms(0.96);
14
		ms--;
15
	}
16
}
17
 
18
 
19
/* new style */
20
int main(void)
21
{
22
          /* INITIALIZE */
23
          /* enable PC5 as output */
24
          DDRC|= (1<<DDC5);
25
 
26
          /* PC5 is 5 (see file include/avr/iom8.h) and 1<<PC5 is 00100000 
27
	   * This can also be written as _BV(PC5)*/
28
          while (1) {
29
                      /* led on, pin=0 */
30
                      PORTC &= ~(1<<PC5);
31
                      delay_ms(100);
32
                      /* set output to 5V, LED off */
33
                      PORTC|= (1<<PC5);
34
                      delay_ms(1000);
35
          }
36
	  return(0);
37
}
38