晶振频率12mhz,实现从p1.0引脚输出一个周期2ms方波(用定时器t0,方式1)
#include <reg51.h>
#include <stdio.h>
sbit P1_0=P1^0;
void T0_int() interrupt 1
{
P1_0=!P1_0;
TF0=0;
}
void main(void)
{
TMOD=0x01;
TH0=0xfc;
TL0=0x18;
EA=1;
ET0=1;
TR0=1;
// Write your code here
while (1)
;
}