中科因仑“3+1”工程特种兵精英论坛

标题: 位定义闪烁流水灯设计实验二 [打印本页]

作者: 张衍波    时间: 2015-4-7 18:26
标题: 位定义闪烁流水灯设计实验二
#include <iom8v.h>
#include <macros.h>
/**********************************************************************
                                  函数数据类型说明                                                                  
**********************************************************************/
#define uchar unsigned char
#define uint unsigned int

/**********************************************************************
                                   延时函数                                                          
**********************************************************************/
void delay(uint MS)                  
{
uint i,j;
for( i=0;i<MS;i++)
for(j=0;j<1141;j++);        //1141是在8MHz晶振下,通过软件仿真反复实验得到的数值
}
/**********************************************************************
                                主函数                                                          
**********************************************************************/
void main()
{
     DDRB=0XFF;
         //PORTB=0XFF;
     while(1)
     {
            PORTB|=BIT(3);//00001000
             delay(1000);
                PORTB&=~BIT(3);
                delay(1000);
     }

}
/**********************************************************************
                                 结束                                                  
**********************************************************************/
[attach]2069[/attach]






欢迎光临 中科因仑“3+1”工程特种兵精英论坛 (http://bbs.enlern.com/) Powered by Discuz! X3.4