#include <reg52.h>
#include <stdio.h>
#include <intrins.h>
#include <absacc.h>
extern serial_initial();
unsigned int a;
unsigned int n;
unsigned int count;
#define SEGMENT XBYTE[0x7fff]
#define BIT_LED XBYTE[0xbfff]
unsigned char code seg_code[]={0x3f,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6f,0x77,0x7C,0x39,0x5E,0x79,0x71,0x00};
main()
{
serial_initial();
TMOD=0x51; //¼ÆêyÆ÷1£¬16λ1¤×÷·½ê½ ¶¨ê±Æ÷0£¬16λ1¤×÷·½ê½,int0¸ßμçƽ′¥·¢
TH0 = 0x4c; //¶¨ê±Îa50ms
TL0 = 0x00;
TL1 = 0x00; //¼Æêy3õÖμÎa0¸ö
TH1 = 0x00;
TR0=1;
TR1=1; //Æô¶ˉ¶¨ê±Æ÷
EA=1; //′ò¿a×üÖD¶Ï
n=0;
count=0;
a=0;
while(1)
{
if(count==20) //¶¨ê±Æ÷é趨Îa1sμÄê±¼ä
{
TR1=0;
TR0=0;
a=n*65536+TH1*256+TL1;
a=a-1;
printf("a=%s",a);
n=0;
count=0;
TH0 = 0x4c; //¶¨ê±Îa50ms
TL0 = 0x00;
TL1 = 0x00; //¼Æêy3õÖμÎa0¸ö
TH1 = 0x00;
TR0=1;
TR1=1; //ÖØDÂÆô¶ˉ¶¨ê±Æ÷
ET0=1;
ET1=1; //′ò¿aÖD¶Ï
EA=1; //′ò¿a×üÖD¶Ï
}
}
}
void TIME0(void) interrupt 1 //¶¨ê±Æ÷0òç3öÖD¶Ï
{
count ++;
TH0 = 0x4c; //¶¨ê±Îa50ms
TL0 = 0x00;
}
void TIME1(void) interrupt 3 //¼ÆêyÆ÷1òç3öÖD¶Ï
{
n++; //òç3ö′Îêy¼ó1
TL1 = 0x00; //¼Æêy3õÖμÎa0¸ö
TH1 = 0x00;
} |