#include <avr/interrupt.h>
/*端口初始化函数*/
void Ports_Init(void)
{
PORTA &= 0b00000111;
DDRA = (1<< DDA7)|(1<< DDA6)|(1<< DDA5)|(1<< DDA4)|(1<< DDA3);
return;
}
char a=6;
void delay1s(void)
{
PORTA = (1<< PA7);
//delay1s();
PORTA = (1<< PA6);
//delay1s();
PORTA = (1<< PA5);
//delay1s();
PORTA = (1<< PA4);
//delay1s();
PORTA = (1<< PA3);
#if 1
//if(a==6)
//{
a--; //如果此语句不注释掉,程序不会返回到main函数的while()循环中,而是过一段时间就复位了。
//}
#endif
return;
}
int main( void )
{
cli(); /*通过置位全局中断屏蔽位来禁止中断*/
Ports_Init();
while(1)
{
PORTA = (1<< PA7)|(1<< PA5)|(1<< PA4)|(1<< PA3)|(1<< PA6);
//PORTA &= 0b00000111;
PORTA = (1<< PA7);
//delay1s();
PORTA = (1<< PA6);
//delay1s();
PORTA = (1<< PA5);
//delay1s();
PORTA = (1<< PA4);
//delay1s();
PORTA = (1<< PA3);
PORTA = (1<< PA7)|(1<< PA5)|(1<< PA4)|(1<< PA3)|(1<< PA6);
delay1s();
}
return 1;
}
windows系统环境
MDK:AVRStudio4.16
C:winavr
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>