📄 speedtest4.c
字号:
#include<reg51.h>
#include<absacc.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit P2_0=P2^0;
sbit P2_1=P2^1;
uchar flag;
//uint store;
uchar n;
uchar time_sgn;
uchar timer0_high,timer0_low;
uchar frag=0;
uchar freq1;
//uchar tempa,tempb;
///
void delay(uint j) /* 简易延时函数 */
{
for(j;j>0;j--);
}
///
main()
{
//uint t_a,t_b;
P2_0=0;
P2_1=1;
//tempa=-10000/256;
//tempb=-10000%256;
//t_a=-1000/256;
//t_b=-1000%256;
EA=1;
IT0=1;
EX0=1;
ET0=1;
//ET1=1;
//PT1=1;
//TH1=-1000/256;
//TL1=-1000%256;
TMOD=0x09;
TR0=1;
while(1)
{
if(n==4)
{
TR0=0;
P2_0=1;
delay(1000);
time_sgn=0;
TR0=1;
}
}
}
//
void int0(void) interrupt 0 using 1
{
uint temp,i;
if(flag==1)
{
flag=0;
timer0_high=TH0;
timer0_low=TL0;
temp=256*timer0_high+timer0_low;
for(i=0;i<4;i++)
{ time_sgn=time_sgn+temp;}
TH0=0;
TL0=0;
}
if(flag==0)
{
flag=1;
TH0=0;
TL0=0;
TR0=1;
}
}
//
void timer0(void) interrupt 1 using 1
{
TH0=0;
TL0=0;
n=n+1;
}
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -