//ICC-AVR application builder : 2009-8-13 13:58:43
// Target : M16
// Crystal: 12.000Mhz
#include <iom16v.h>
#include <macros.h>
void port_init(void)
{
PORTC = 0x00;
DDRC = 0x00;
PORTB = 0xFF;
DDRB = 0x00;
PORTA = 0x00; //m103 output only
DDRA = 0xFF;
PORTD = 0xFF;
DDRD = 0x00;
}
void watchdog_init(void)
{
WDR(); //this prevents a timout on enabling
WDTCR = 0x0F; //WATCHDOG ENABLED - dont forget to issue WDRs
}
void delay_1ms(void)
{
unsigned int i;
for (i=1;i<570;i++)
;
}
void delay(unsigned int n)
{
unsigned int i=0;
while (i<n)
{
delay_1ms();
i++;
}
}
void main(void)
{
unsigned char oldP,newP;
port_init();
watchdog_init();
newP=0;
oldP=0;
for(;;)
{
oldP=PINA;
if(oldP^newP)
{
delay(20);
newP=PINA;
if(oldP&newP)
{
newP&=oldP;
PORTC^=newP;
}
}
WDR();
}
}
评论0