上传者: 45913029
|
上传时间: 2023-06-19 15:46:02
|
文件大小: 22KB
|
文件类型: PDSPRJ
初学者必备 动态链接的定时器
#include
unsigned char count=0;
unsigned char miao=0;
sbit P2_7=P2^7;
sbit P1_2=P1^2;
sbit P1_3=P1^3;
void timer_1() interrupt 3
{
TH1 = ( 65536-50000 )/256;
TL1 = ( 65536-50000 )%256;
count++;
if(count==20)
{
count=0;
miao++;
if(miao==100)miao=0;
}
}
void disp (unsigned char i)
{
unsigned int j;
unsigned char led[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
P1_2=0;
P1_3=0;
P0=led[i/10];
P1_2=1;
for(j=0;j<100;j++);
P1_2=0;
P1_3=0;
P0=led[i%10];
P1_3=1;
for(j=0;j<100;j++);
}