⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 30-14-2.c

📁 C51程序应用例子,自己的学习历程,希望可以帮到大家
💻 C
字号:
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#include<reg52.h>

sbit P10=P1^0;
sbit P34=P3^4;
sbit P35=P3^5;
sbit K1=P3^2;

static uchar Tosc;


void main(void)
{
//uint n;
TMOD=0x11; //计数器0/1均工作在方式1的16位计数模式

TH0=0x3C;
TL0=0xB0;
TH1=0x3C;
TL1=0xB0; //预置15536,计数50000,用6M晶振,计时0.1s

TR0=1;
//TR1=1;

ET0=1;
ET1=1;

EA=1;

while(1)
{
;


}

}


timerT0() interrupt 1
{


Tosc++;

if(Tosc==10)
{
Tosc=0;
//if(Tosc!=0)

P10=1;

}

TR1=1;
TR0=0;
}


timerT1() interrupt 3
{
static uchar Duty;

Duty++;

if(Duty==Tosc)
{
Duty=0;
P10=0;

}
TR0=1;
TR1=0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -