//包含基本的IO寄存器信息 #include \ //Altera定义的数据类型 #include \ //延时函数
#define seg *(volatile unsigned char *) SMG_SEG_BASE //代表数码管的段码地址
#define bit *(volatile unsigned char *) SMG_BIT_BASE //代表数码管的位选地址
const alt_u8 duan[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//共阳数码管的0到9的段码 0 1 2 3 4 5 6 7 8 9
void display()
{
alt_u8 i;
for(i=0;i<8;i++) {
bit = i ;
seg = ~duan[i]; 要显示的字符
usleep(500000); } }
int main(void) {
while(1) {
display(); }
return 0; }
//输出