//用动态扫描方法和定时器1在数码管的前三位显示出秒表,精确到1%秒,即后两位显示1%秒,一直循环下去。#include#define uint unsigned int#define uchar unsigned charsbit wela=P2^7;sbit dula=P2^6;uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};void init();void display(uchar fen,miao1,miao2);void delay(uchar);uchar tt,fen,miao1,miao2;uint temp;void main(){init();while(1){if(tt==70){tt=0;temp++;if(temp==600)temp=0; fen=temp/100;miao1=temp%100/10;miao2=temp%10;}display(fen,miao1,miao2);}}void display(uchar fen,miao1,miao2){dula = 1;P0 = table[fen];dula = 0;P0 = 0xff;wela = 1;P0 = 0xfe;wela = 0;delay(1);dula = 1;P0 = table[miao1];dula = 0;P0 = 0xff;wela = 1;P0 = 0xfd;wela = 0;delay(1);dula = 1;P0 = table[miao2];dula = 0;P0 = 0xff;wela = 1;P0 = 0xfb;wela = 0;delay(1);}void delay(uchar z){uchar x,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}void init(){temp=0;TMOD=0x01;TH1=(65536-10000)/256;TL1=(65536-10000)%256;EA=1;ET1=1;TR1=1;}void timer1() interrupt 3{TH1=(65536-10000)/256;TL1=(65536-10000)%256;tt++;} ","
没太懂你那定时器是什么,但利用555可以设置计时输出矩形波,用单片机定时也行
传统51单片机定时器是16位的定时器,系统时钟给它提供时钟源,每一个脉冲使定时器加一,直到溢出会产生定时器中断。