Subversion Repositories svnkaklik

Rev

Rev 547 | 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);
715 kaklik 25
//          DDRC|= (0x00);
495 kaklik 26
 
27
          /* PC5 is 5 (see file include/avr/iom8.h) and 1<<PC5 is 00100000 
28
	   * This can also be written as _BV(PC5)*/
29
          while (1) {
30
                      /* led on, pin=0 */
31
                      PORTC &= ~(1<<PC5);
32
                      delay_ms(100);
33
                      /* set output to 5V, LED off */
715 kaklik 34
                      PORTC |= (1<<PC5);
495 kaklik 35
                      delay_ms(1000);
36
          }
37
	  return(0);
38
}
39