发布网友
发布时间:2024-12-21 14:13
共1个回答
热心网友
时间:2025-01-23 04:32
是C51么?
假设晶振频率12MHz,用P1.0作为方波输出端口。
#include <stdio.h>
#include <reg51.h>
sbit P1_0=P1^0;
void main(void)
{
int count=0;
TMOD=0x02;
TH0=0x06;
TL0=0x06;
EA=1;
ET0=1;
TR0=1
while(1);
}
void t0_int(void) interrupt 1
{
TH0=0x06;
TL0=0x06;
count++;
if(count==2000)
{
P1_0=~P1_0;
count=0;
}
}