AVR MEGA16想用定时器2 使PD口连接的led闪烁 现在这个程序为什么不行 CVAVR 5
#include<mega16.h>#defineuintunsignedint#defineucharunsignedchar#defineBIT(x)(1<<(x))...
#include<mega16.h>
#define uint unsigned int
#define uchar unsigned char
#define BIT(x) (1 << (x))
uchar deng=0xff;
uint i=0;
interrupt [TIM2_OVF] void time2_ovf_isr(void)
{
i++;
if(i==10)
{
i=0;
deng=~deng;
}
TCNT2=0x05;
}
void main()
{
DDRD=0xff;
PORTD=0x00;
TCCR2=0x07;
TCNT2=0x05;
TIMSK|=BIT(6);
SREG|=BIT(7);
while(1)
{
PORTD=deng;
}
} 展开
#define uint unsigned int
#define uchar unsigned char
#define BIT(x) (1 << (x))
uchar deng=0xff;
uint i=0;
interrupt [TIM2_OVF] void time2_ovf_isr(void)
{
i++;
if(i==10)
{
i=0;
deng=~deng;
}
TCNT2=0x05;
}
void main()
{
DDRD=0xff;
PORTD=0x00;
TCCR2=0x07;
TCNT2=0x05;
TIMSK|=BIT(6);
SREG|=BIT(7);
while(1)
{
PORTD=deng;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询