|
发表于 2005-4-12 22:53:06
|
显示全部楼层
把delay_short(1000); 改为 delay_short(200); 图象不闪烁,而且更明亮了。
我也上传一个,把avrboy的做了修改:
//I LOVE YOU!
//avr-51實驗板接線:
//pa0-pa7 ----> je2.1 - je2.8
//pc0-pc7 ----> je1.8 - je1.1
//蜂鸣器接口JM -------> pc0-pc7中任一个 。有响动更有意思一些,不是吗?呵呵
#include <iom16v.h>
#include <macros.h>
const unsigned char led_str[ ] =
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x82,0xFE,0x82,0x00,0x00,
0x00,0xFE,0x80,0x80,0x80,0x80,0x00,0x7C,0x82,0x82,0x82,0x7C,0x00,0x3E,0x40,
0x80,0x40,0x3E,0x00,0xFE,0x92,0x92,0x92,0x82,0x00,0x00,0x00,0x0E,0x10,0xE0,
0x10,0x0E,0x00,0x7C,0x82,0x82,0x82,0x7C,0x00,0x7E,0x80,0x80,0x80,0x7E,0x00,
0x0C,0xBE,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};
unsigned char led_data[8] ;
void port_init(void)
{
PORTA = 0xFF;
DDRA = 0xFF;
PORTB = 0xFF;
DDRB = 0xFF;
PORTC = 0xFF;
DDRC = 0xFF;
PORTD = 0x00;
DDRD = 0x00;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void delay_long(unsigned int t)
{unsigned int i;
unsigned char j;
for (i=0;i<t;i++)
{
for (j=0;j<100;j++);
};
}
void delay_short(unsigned int t)
{
unsigned int i;
for (i=0;i<t;i++);
}
void main(void)
{
unsigned char led_row,k,w,z;
init_devices();
for (;;)
{
for (led_row=0;led_row<8;led_row++)
{
PORTA = 0xFF;
PORTA =~BIT(led_row);
PORTB =led_data[led_row];//我的C口烧坏了,呜呜!只得用B口代替。
PORTC =led_data[led_row];
delay_short(200);
k++;
if (k>=100)
{
w++;
k = 0;
for (z=0;z<7;z++)
{
led_data[z] = led_str[z+w];
}
if (w>=70)
{
w=0;
}
}
}
};
}
===============================================================================
点击此处下载armok0145205.txt |
|