深海的小鱼儿

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

avrstudio 5开发程序:

备注:

   1.在proteus的里面可以导入elf文件,来实现也就是说不一定非要生成hex文件

   2.关键点:是要消影子,这点在原来的书上是没有的,可能是编书时的错漏。

源代码:

/*
* eight_led_return.c
* Project: eight led
* Created: 2011-3-25 12:23:09
* Author : xmphoenix.fish
*/
#include <avr/io.h>
#include<util/delay.h>
#define F_CPU 8000000UL
//led light char
const char table[]={0xC0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};

int main(void)
{
    char i;
    DDRE= 0xff;DDRF = 0xff;//set the port c and d for input
    PORTF=0x01;

    while(1)
    {
        //TODO:: Please write your application code
        for (i=0;i<8;i++)
        {
            PORTF=_BV(i);//the operation _BV() contain in system
            PORTE=table[i];
            _delay_us(2);//strip the false figure
            PORTF=0x00;
            PORTE=0xff;
            _delay_us(2);
        }
    }
    return 0;
}

截图:

2011-3-25-12-55

posted on 2011-03-25 12:55  深海的小鱼儿  阅读(457)  评论(0编辑  收藏  举报