/*------------------------------
Function: generate pulse signal
Author: Zhang Kaizhou
Date: 2019-5-15 22:50:43
------------------------------*/
#include <reg51.h>
#define uchar unsigned char
sbit output = P1^0;
uchar period = 250;
uchar high = 50;
uchar tcount = 0;
void timer0() interrupt 1 using 1
{
TH0 = (65536 - 10000) / 256;
TL0 = (65536 - 10000) % 256;
tcount++;
if(tcount == high)
{
output = 0;
}else if(tcount == period){
tcount = 0;
output = 1;
}
}
void main()
{
TMOD = 0x01; // set Timer1, working at mode 1(16 bit timer)
TH0 = (65536 - 10000) / 256; // set initial value
TL0 = (65536 - 10000) % 256;
EA = 1; // open global interrupt
ET0 = 1; // open Timer0 interrupt
TR0 = 1; // start Timer0
while(1);
}
11-28
6270

01-16
4453

07-12
4395

“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交
评论




查看更多评论

打赏作者
¥2
¥4
¥6
¥10
¥20
输入1-500的整数



