#include "system.h"
#include "altera_avalon_pio_regs.h" //包含基本的IO寄存器信息
#include "alt_types.h" //Altera定义的数据类型
#include "unistd.h" //延时函数
#define seg *(volatile unsigned char *) SM_SEG_BASE
#define bit *(volatile unsigned char *) SM_BIT_BASE
const alt_u8 duan[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
alt_u8 num[8] = {0,0,0,0,0,0,0,0};
void display(alt_u16 i)
{
alt_u8 j;
num[0] = i % 10;
num[1] = (i / 100)%10;
num[2] = (i / 1000)%10;
num[3] = (i / 10000)%10;
num[4] = (i / 100000)%10;
num[5] = (i / 1000000)%10;
num[6] = (i / 10000000)%10;
num[7] = (i / 100000000)%10;
for(j=0; j<8; j++)
{
bit = ~(0x01 << j); //位选低位有效
seg = duan[num[j]];
usleep(500);
}
}
int main(void)
{
alt_u16 n;
while(1)
{
display(n);
n++;
}
return 0;
}
用户582343 2010-1-6 21:10
用户39557 2009-12-5 16:26
用户222124 2009-9-14 08:09
用户188034 2009-9-13 22:03