- #include <reg51.H>
- unsigned char XUEHAO[]={2,0,2,1,3,9,1,5};
- unsigned char NixieTable[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7f,0x39,0x3f,0x79,0x71};
- unsigned char count;
- void main()
- {
- TMOD = 0x01; //set timer0 as mode1 (16-bit)
- TH0=(65536-918)/256; //初值高位,定时1ms
- TL0=(65536-918)%256;//初值低位
- TR0 = 1; //timer0 start running
- ET0 = 1; //enable timer0 interrupt
- EA = 1; //open global interrupt switch
- while (1); //loop
- }
- void tm0_isr() interrupt 1
- {
- TH0=(65536-918)/256; //初值高位,定时1ms
- TL0=(65536-918)%256;//初值低位
- P0=0x00;
- P2=~(0x01<<count);
- P0=NixieTable[XUEHAO[count]];
- count=++count%8;
- }
复制代码
|