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

📄 pwm可调用.txt

📁 数控直流电源和变频电源程序在c环境下编译
💻 TXT
字号:
#include <reg51.h>
#include <stdio.h>
#include <math.h>
#define unit unsigned int

sbit P1_0=P1^0;
int a=250,b=250,th0,tl0,th1,tl1;

void init()
{
 TMOD=0X11;
 TH0=th0;
 TL0=tl0;
 TH1=th1;
 TL1=tl1;
 }
void main()
{
 th0=(65536-a)/256;
 tl0=(65536-a)%256;
 th1=(65536-b)/256;
 tl1=(65536-b)%256;
 init();
 P1_0=1;
 EA=1;
 ET0=1;
 ET1=1;
 TR0=1;
 TR1=0;
 while(1);
  }
void timer0(void) interrupt 1
 {
     P1_0=~P1_0;
     TR1=1;
     TR0=0;
     TH0=th0;
     TL0=tl0;
   }

void timer1(void) interrupt 3
{
 P1_0=~P1_0;
 TR0=1;
 TR1=0;
 TH1=th1;
 TL1=tl1;
  }

⌨️ 快捷键说明

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