在P1.0 引脚上输入周期为2ms方波
追答应该是输出2ms方波吧。
刚好有个现成的
#include
#define uchar unsigned char
sbit P1_0 = P1^0;
void InitTimer0( )
{
TMOD = 0x01; //定时器0,工作方式1
TH0 = (65536-1000)/256;
TL0 = (65536-1000)%256; //1ms中断一次
EA = 1;
ET0 = 1;
TR0 = 1;
}
void main(void)
{
InitTimer0();
while(1);
}
void Timer0Interrupt(void) interrupt 1
{
TH0= (65536-1000)/256;
TL0= (65536-1000)%256;
P1_0=~P1_0;
}