Blame | Last modification | View Log | Download
/*********************************************
* vim: set sw=8 ts=8 si :
* Author: Guido Socher, Copyright: GPL
* This program is to test the led connected to
* PC5.
* See http://linuxfocus.org/English/November2004/
* for details.
* Chip type : ATMEGA644
* Clock frequency : Internal clock 1 Mhz (factory default)
*********************************************/
#include <avr/io.h>
#include <inttypes.h>
#define F_CPU 16000000UL // 8 MHz
#include <util/delay.h>
#define LED PINC5
void cekej(int ms)
{
// we use a calibrated macro. This is more
// accurate and not so much compiler dependent
// as self made code.
while (ms)
{
_delay_ms(0.96);
ms--;
}
}
int main(void)
{
/* INITIALIZE */
/* enable PC5 as output */
DDRC|= (1<<LED);
/* PC5 is 5 (see file include/avr/iom8.h) and 1<<PC5 is 00100000
* This can also be written as _BV(PC5)*/
while (1) {
/* led on, pin=0 */
PORTC|= (1<<LED);
cekej(1000);
/* set output to 5V, LED off */
PORTC &= ~(1<<LED);
cekej(100);
}
return(0);
}