分类: 嵌入式
2014-07-01 22:31:05
TMOD = 0x01;
TH0 = (65536-50000)/256; //给计数器装初值,格式如此
TL0 = (65536-50000)%256;
TR0 = 1;
EA = 1; //开总中断
ET0 = 1; //开定时器中断
D3 = 1;
P0 = 0x00;
D3 = 0;
P1 = 0xfe;
delay(200);
TH0 = (65536-50000)/256; //重新装初值if(m == 40) //判断所需时间是否已经满足,40倍的定时时间既是40x50ms ==2s
TL0 = (65536-50000)%256;
m++;
m = 0;
D2 = 1;
P0 = table[k]; //将table数组里的值赋值,实现数码管显示
D2 = 0;
k++;
if(k ==16) //清0实现数码管由0-F循环显示}
k = 0;