晶振12M
ATMEGA16
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#define BIT(x) (1<<x)
typedef unsigned int u8;
typedef unsigned char u16;
int main(void)
{
DDRD=0xff;
PORTD=0xff;
TCCR1B|=BIT(CS12);//256分频
TCNT1H=0x48;
TCNT1L=0xe4;
TIMSK|=BIT(TOIE1);//定时器使能位开启
sei();//中断开启
while1();
}
ISR(TIMER1_OVF_vect)
{
PORTD&=~BIT(0);
TCNT1H=0x48;
TCNT1L=0xe4;
}
|