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;
}
截图: